Open aaronpk opened 6 years ago
Did a little digging and it looks like this was already fixed in master! https://github.com/ezyang/htmlpurifier/pull/148 Looking forward to the next release! 🎉
think there's a better way to sort out that issue. As we all know that email library not supported in php 7.2 and that's why error occured.
Quick Solution :
think there's a better way to sort out that issue. As we all know that email library not supported in php 7.2 and that's why error occured.
Quick Solution :
- Go to cPanel
- Select PHP version
- change it to 7.1 instead of 7.2
It's an easy way to solve this problem in a second.
So what is the real solution to this? I am experiencing this error with version 4.11.0 in PHP 7.2 and I don't consider rolling back to PHP 7.1 to be a reasonable solution. Is PHP to blame for how this function is being called? It looks like symfony/polyfill is defining that constant. Maybe it shouldn't be?
To avoid this issue in PHP 7.2, apparently two constants need to be defined but whose responsibility is that and what are the values supposed to be? I'm really surprised the PHP devs decided to deprecate that constant yet leave it as the default value for the third parameter of idn_to_ascii(). This screenshot is from the offending block of code in this library's Host.php file.
@benjaminkohl Can you file a new bug for this?
Was this satisfactorily resolved? I'm seeing errors similar to this in an app where this library is a dependency (Freescout): I'm seeing the following error on PHP 7.2 and above:
idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) {"userId":1,"email":"jay@modx.com","exception":"[object] (ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103)
I'm not sure if this is a new issue or if I'm supposed to do something to get this to work reliably?
Web Server: nginx/1.16.1 PHP: PHP 7.3.11 OS: centOS6
Any help or guidance would be appreciated.
did freescout update to a newer version? :)
The version used is 4.12, so, the PHP7.2+ compatibility should be fine according to your docs. That said, they completely dismissed the issue out of hand stating that the deprecation notice and the simultaneous 500 error that occurs are not related. While I agree that something that throws a deprecation notice isn't the specific culprit of the 500, the 500 still occurs and still stops the application from working when the notice is logged at PHP 7.2+. Thoughts?
in 4.12 there is not supposed to be any occurrence of INTL_IDNA_VARIANT_2003. Can you grep in Freescout and see where the string INTL_IDNA_VARIANT_2003 occurs?
Error occurs here on PHP7.3: https://github.com/ezyang/htmlpurifier/blob/master/library/HTMLPurifier/AttrDef/URI/Host.php#L103
The only way to fix this seems to be:
try {
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) {
$string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
} else {
$string = idn_to_ascii($string);
}
} catch (\Exception $e) {
}
Is it ok to create a pull request for this https://github.com/ezyang/htmlpurifier/issues/163#issuecomment-886888844? PHP developers made a mistake for which there is no other solutions.
We need a reproducer and https://github.com/ezyang/htmlpurifier/issues/163#issuecomment-886888844 isn't a valid fix
Did you check phpinfo()
for the libicu version on the system that's producing the error?
I'm getting this bizarre error in some cases under PHP 7.2. Apparently the idn_to_ascii function deprecated the
INTL_IDNA_VARIANT_2003
variant in PHP 7.2, and you're supposed to useINTL_IDNA_VARIANT_UTS46
instead now. However, PHP seems to be still usingINTL_IDNA_VARIANT_2003
as the default if none is specified. This ends up causing an exception.I think this is wrong behavior of PHP, but it would be easier to fix in this library calling the
idn_to_ascii
function. I've patched my running instance to callidn_to_ascii($string,0,INTL_IDNA_VARIANT_UTS46)
already.Has anyone else encountered this issue?