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

Issues with php7.2 and idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated #32

Closed
terryupton opened this issue Mar 16, 2020 · 2 comments
Assignees

Comments

@terryupton
Copy link

Currently getting deprecated issues and breakages when using this package with PHP7.2
Looks like it is down to deprecated the INTL_IDNA_VARIANT_2003 which is still used as the default in PHP7.2.

https://www.php.net/manual/en/migration72.deprecated.php

INTL_IDNA_VARIANT_2003 variant ¶
The Intl extension has deprecated the INTL_IDNA_VARIANT_2003 variant, which is currently being used as the default for idn_to_ascii() and idn_to_utf8(). PHP 7.4 will see these defaults changed to INTL_IDNA_VARIANT_UTS46, and the next major version of PHP will remove INTL_IDNA_VARIANT_2003 altogether.

I believe the issue is at lines 111 inside StringUtils.php

public static function idnToAscii($domain)
    {
        // INTL_IDNA_VARIANT_UTS46 defined PHP 5.4.0 or later
        if (defined('INTL_IDNA_VARIANT_UTS46')) {
            return idn_to_ascii($domain, IDNA_ALLOW_UNASSIGNED, INTL_IDNA_VARIANT_UTS46);
        }

        return idn_to_ascii($domain, IDNA_ALLOW_UNASSIGNED);
    }

These might be of use?
ezyang/htmlpurifier#163
https://aaronparecki.com/2018/02/06/9/

@nojimage nojimage self-assigned this Mar 16, 2020
@nojimage
Copy link
Owner

The presented code is convert to ascii from idn using INTL_IDNA_VARIANT_UTS46 if NTL_IDNA_VARIANT_UTS46 is defined. This code is corresponded to the deprecation of INTL_IDNA_VARIANT_2003.

I think the cause of the error is that INTL_IDNA_VARIANT_UTS46 is not defined.
The PHP manual states that INTL_IDNA_VARIANT_UTS46 can be used with ICU 4.6 or later, so check the ICU version of the server.

https://www.php.net/manual/en/intl.constants.php

@nojimage
Copy link
Owner

nojimage commented Mar 16, 2020

I found that ICU4.2 is used by default for RHEL/CentOS 6.

If you are using RHEL/CentOS 6, installing PHP from the remi repository is the best choice. If you use remi, you can use the new ICU with RHEL/CentOS 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants