Skip to content

ext/intl: report argument #3 ($variant) for an invalid IDNA variant - #23533

Merged
devnexen merged 2 commits into
php:masterfrom
lacatoire:fix/idn-variant-arg-num
Sep 2, 2026
Merged

ext/intl: report argument #3 ($variant) for an invalid IDNA variant#23533
devnexen merged 2 commits into
php:masterfrom
lacatoire:fix/idn-variant-arg-num

Conversation

@lacatoire

Copy link
Copy Markdown
Member

php_intl_idn_handoff() parses $domain, $flags, $variant, so the variant check must report argument 3. It hardcodes 2, so idn_to_ascii() and idn_to_utf8() blame $flags for a value that was passed as $variant.

Before:

ValueError: idn_to_ascii(): Argument #2 ($flags) must be INTL_IDNA_VARIANT_UTS46

After:

ValueError: idn_to_ascii(): Argument #3 ($variant) must be INTL_IDNA_VARIANT_UTS46

Only the error message changes. The existing test is updated and a named-argument case is added, where the wrong number was the most misleading.

php_intl_idn_handoff() takes domain, flags, variant, so the variant
check must report argument 3; it hardcodes 2, which makes idn_to_ascii()
and idn_to_utf8() blame $flags for a value carried by $variant.
Comment thread ext/intl/idn/idn.cpp Outdated
@devnexen

devnexen commented Sep 2, 2026

Copy link
Copy Markdown
Member

lgtm otherwise

The message concatenated PRId32 as a literal instead of using it as a
conversion, so it read "must be less than d bytes" and INT32_MAX was
never printed.
@devnexen
devnexen merged commit 2bbe62e into php:master Sep 2, 2026
18 checks passed
@lacatoire
lacatoire deleted the fix/idn-variant-arg-num branch September 2, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants