Skip to content

Conversation

@yguedidi
Copy link

@yguedidi yguedidi commented Feb 2, 2025

Targeting 2.x as this is the version used by wallabag for now, and I want to remove an abandoned package.

@jtojnar
Copy link
Collaborator

jtojnar commented Feb 2, 2025

Please cherry-pick 06394db, it does more validation.

@yguedidi
Copy link
Author

yguedidi commented Feb 2, 2025

@jtojnar done

@coveralls
Copy link

coveralls commented Feb 22, 2025

Coverage Status

coverage: 95.258% (-0.2%) from 95.505%
when pulling da1941b on yguedidi:replace-punycode
into 3a481db on j0k3r:2.x.

@jtojnar jtojnar requested a review from j0k3r February 22, 2025 15:55
@jtojnar
Copy link
Collaborator

jtojnar commented Feb 22, 2025

Thanks, I rebased in on top of CI fixes from #363 and applied a workaround for the warnings due to unfortunate decision in PHP 7.2 to deprecate the default argument without making sure the alternative exists (see the commit message in the second commit). @j0k3r does that sound reasonable to you?

j0k3r and others added 2 commits February 22, 2025 17:06
Because it's no more maintained.

(cherry picked from commit 06394db)
As per <https://www.php.net/manual/en/function.idn-to-ascii.php>, PHP 7.2 deprecated the `INTL_IDNA_VARIANT_2003` constant. But until PHP 7.4, it was still used as the default value of the `$variant` argument and will trigger a deprecation warning (https://github.com/php/php-src/blob/php-7.3.0/ext/intl/idn/idn.c#L318-L320). This in turn broke tests on PHP 7.2 and 7.3:

    1x: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated
      1x in GrabyTest::testUrlWithAccent from Tests\Graby

This is not an issue on `master` since we require PHP ≥ 7.4 there.

One option would be passing the `INTL_IDNA_VARIANT_UTS46` explicitly to the `$variant` argument so that it is consistent across all supported PHP versions. Unfortunately, this would require raising the requirements to ICU ≥ 4.6, which would break systems that have `intl` extension linked against ancient ICU (allowed on PHP before 7.4: https://github.com/php/php-src/blob/php-7.2.0/ext/intl/idn/idn.c#L85-L87).

Polyfill does support emulating `INTL_IDNA_VARIANT_UTS46` but it will not do anything if the presence of any `intl` extension is detected (https://github.com/symfony/polyfill-intl-idn/blob/v1.26.0/bootstrap.php#L14-L16). So it will not help us when the constant we want does not actually exist.

We could silence the warning with `@` but that is always iffy.

For now, let’s use the polyfill explicitly on PHP 7.2 or 7.3 built with `intl` extension linked against ICU < 4.6. The PHP implementation will be a bit slower but the situation is pretty unlikely in my opinion.
@j0k3r j0k3r merged commit 75437c1 into j0k3r:2.x Feb 24, 2025
16 checks passed
@yguedidi yguedidi deleted the replace-punycode branch February 24, 2025 07:33
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

Successfully merging this pull request may close these issues.

4 participants