Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation on localhost/mail.php due to php.net/function.hexdec on PHP 7.4 #798

Closed
masiorama opened this issue Apr 12, 2021 · 24 comments · Fixed by #944
Closed

Deprecation on localhost/mail.php due to php.net/function.hexdec on PHP 7.4 #798

masiorama opened this issue Apr 12, 2021 · 24 comments · Fixed by #944
Assignees
Labels
Milestone

Comments

@masiorama
Copy link

ISSUE TYPE

  • Bug Report

I switched to PHP 7.4 the ambient for some of my projects, and visiting devilbox/mail dashboad I notice a lot of warning like this:

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /var/www/default/include/vendor/Mail/mimeDecode.php on line 838

Checking the php function it is stated that

hexdec() will ignore any non-hexadecimal characters it encounters. As of PHP 7.4.0 supplying any invalid characters is deprecated.

Right now I have not time to investigate a bit more.
Will write down more infos as soon as possible.
Cheers!

@masiorama masiorama added the bug label Apr 12, 2021
@tiktaz
Copy link

tiktaz commented Apr 16, 2021

I'm facing the same problem. Is it possible to add this correction around line 838 of /var/www/default/include/vendor/Mail/mimeDecode.php ? I dunno how to update this file to submit a PR.

if (ctype_xdigit($matches[0])) {
    return chr(hexdec($matches[0));
}

@llaville
Copy link
Contributor

Perharps a better alternative will be to replace outdated PEAR Mail_mimeDecode package, by a new alternative solution.

See https://stackoverflow.com/questions/4721410/best-way-to-handle-email-parsing-decoding-in-php

I suggest eXorus answer with his solution https://github.com/php-mime-mail-parser/php-mime-mail-parser

@stale
Copy link

stale bot commented Jul 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the issue:stale This issue has become stale and is marked for auto-close label Jul 20, 2021
@cytopia cytopia removed the issue:stale This issue has become stale and is marked for auto-close label Jul 21, 2021
@cytopia
Copy link
Owner

cytopia commented Jan 30, 2022

@masiorama @tiktaz can you guys let me know how to reproduce it. I'm unable to get this error with PHP 7.4

@cytopia cytopia self-assigned this Jan 30, 2022
@cytopia cytopia modified the milestones: v1.10.1, v1.10.2 Jan 30, 2022
@masiorama
Copy link
Author

Hi @cytopia neither I was able to reproduce the error. Since then (when I opened the issue) I migrated my dev env to WSL2, installing Devilbox inside Ubuntu (on WSL2), and I have the previous env no more. What I can say is that building up the same stack I see no error in the mail section of Devilbox dashboard.

@cytopia
Copy link
Owner

cytopia commented Jan 31, 2022

Alright, I'll give it a few more days to wait for @tiktaz and check if he's still facing this issue and if not I'm gonna close this one.

@lesteak
Copy link

lesteak commented Jan 31, 2022

I've been experiencing this issue for some time with PHP7.4 and still am after updating to Devilbox 1.10.1 today. Thanks

@cytopia
Copy link
Owner

cytopia commented Jan 31, 2022

I've been experiencing this issue for some time with PHP7.4 and still am after updating to Devilbox 1.10.1 today. Thanks

@lesteak Can you provide instructions on how one could reproduce this issue.

@tiktaz
Copy link

tiktaz commented Feb 9, 2022

Sorry I quit my last job and I'm not using Devilbox for the new one.
The way to get the bug was to sent a email containing some HTML tags and try to read them from localhost/mail.php.

@cytopia
Copy link
Owner

cytopia commented Apr 8, 2022

Perharps a better alternative will be to replace outdated PEAR Mail_mimeDecode package, by a new alternative solution.

See https://stackoverflow.com/questions/4721410/best-way-to-handle-email-parsing-decoding-in-php

I suggest eXorus answer with his solution https://github.com/php-mime-mail-parser/php-mime-mail-parser

@llaville I had a look, unfortunately it's not gonna do it, as I do need support starting from PHP 5.3 onwards.

@cytopia
Copy link
Owner

cytopia commented Apr 8, 2022

I am going to close this issue due to not being able to reproduce it (might have gone away with recent updates).

What I tried:

  • Html emails
  • Unicode characters
  • Really large emails
  • PHP 7.4 -> PHP 8.1

I've never encountered the deprecation warning.

If you encounter this again, please let me know exactly how it was triggered

@cytopia cytopia closed this as completed Apr 8, 2022
@massiws
Copy link

massiws commented Dec 29, 2022

This error came up again after last update v-3.0.0 (both beta-0.1 and beta-0.2).
Tested with the same results on:

  • Laravel project
  • sending Password Reset link (Laravel default notification)
  • both PHP 8.0 and PHP 8.1
  • HTML email
  • short text including characters è, and é (decimal 232, 233)

mail

@cytopia
Copy link
Owner

cytopia commented Dec 29, 2022

@massiws can you reproduce this behaviour with the "Send test Email" feature in the intranet?

@masiorama
Copy link
Author

masiorama commented Dec 29, 2022

It showed up again to me too.
This morning I upgraded from 2.2.0 to 2.4.0, and on PHP 8.0 it shows the same deprecation errors @massiws pasted right above.

@cytopia
Copy link
Owner

cytopia commented Dec 29, 2022

I would require a command or a php snippet with which I can produce an email that triggers this error.

@masiorama
Copy link
Author

I am not sure what you are suggesting @cytopia. I am using no snippet at all, it is enough to visit devilbox "catch all emails" page to see all those deprecations. It is not related to any custom php project/script from my side.
I guess @massiws could be on the same page.

@cytopia
Copy link
Owner

cytopia commented Dec 29, 2022

@masiorama what I am suggesting is any means of creating such an email. Whenever I create emails with UTF-8 chars they all display nicely on the vhost page. I don't see the errors, thus I can't really troubleshoot it. So all I need is the piece of code with which you send the email. Does this make sense now?

@masiorama
Copy link
Author

So you mean the deprecation is triggered by any email already trapped by devilbox? If so tomorrow I will check if the multiple messages are gone if I remove all emails, and I will dig a bit deeper and keep you posted, thanks.

@cytopia
Copy link
Owner

cytopia commented Dec 29, 2022

So you mean the deprecation is triggered by any email already trapped by devilbox? If so tomorrow I will check if the multiple messages are gone if I remove all emails, and I will dig a bit deeper and keep you posted, thanks.

Yes, it is seemlingly the "view/show emails" page. Also @massiws mentioned that those mails were send by other means and the error is shown on that page.

@cytopia cytopia reopened this Dec 29, 2022
@massiws
Copy link

massiws commented Dec 29, 2022

@massiws can you reproduce this behaviour with the "Send test Email" feature in the intranet?

@cytopia , using the "Send test Email" I can't reproduce the error: let me know if I can investigate more deeply

@masiorama
Copy link
Author

@cytopia indeed removing previous trapped emails the deprecations are gone and, as @massiws said, using "send test email" does not trigger them.

In my case the trapped emails were not customized "password recovery" email sent by laravel instance configured like this:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

@cytopia
Copy link
Owner

cytopia commented Dec 30, 2022

I don't have a laravel setup (at least not one with a registration page). Can you share the mbox file from inside the container at /var/mail/devilbox (If it doesn't contain any sensitive information)

@cytopia
Copy link
Owner

cytopia commented Jan 2, 2023

I was able to reproduce it with PHPMailer. I've implemented the fix as suggested by @tiktaz in this PR #944

This fixes it (at least for my tests)

@massiws
Copy link

massiws commented Jan 2, 2023

I don't have a laravel setup (at least not one with a registration page). Can you share the mbox file from inside the container at /var/mail/devilbox (If it doesn't contain any sensitive information)

Below the /var/mail/devilbox content (only plain text):
mail

I can confirm that last beta-0.3 release fixes the issue.

@cytopia cytopia linked a pull request Jan 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants