Skip to content

ext/iconv/tests/bug76249.phpt: fallback for non-GNU iconv()#22540

Open
orlitzky wants to merge 1 commit into
php:PHP-8.4from
orlitzky:non-gnu-iconv-fallback
Open

ext/iconv/tests/bug76249.phpt: fallback for non-GNU iconv()#22540
orlitzky wants to merge 1 commit into
php:PHP-8.4from
orlitzky:non-gnu-iconv-fallback

Conversation

@orlitzky

@orlitzky orlitzky commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixes one failure in #22413. The commit message and comment explain the rationale, but here are some references.

  1. The libiconv docs say that //IGNORE will ignore only untranslatable sequences; invalid sequences are an error instead.
  2. The libiconv docs also say that both invalid and untranslatable sequences will be ignored. Whether or not this should be an error is unclear.
  3. The glibc docs ambiguously say "characters that cannot be converted" will be ignored, and do not mention the error status. I would interpret "characters" to mean valid characters, but I am reaching.
  4. The man-pages page for iconv_open says that only untranslatable sequences are ignored.
  5. POSIX says that //IGNORE should ignore both invalid and untranslatable sequences. Invalid sequences are not an error in this case.
  6. The musl implementation of iconv does not support //IGNORE at all.
  7. FreeBSD apparently uses some other ignore mechanism.

This test fails on musl, where iconv trips over the //IGNORE suffix.
It is not obvious that //IGNORE is required to trigger the issue in
the first place, but since we are ensuring that a security bug is
fixed, it is better to include it where possible.

This commit updates the test to append //IGNORE only on the two GNU
iconv implementations. Others may support it eventually, but at the
moment, despite being part of POSIX, support is inconsistent (as
evidenced by musl, if nothing else). In any case, we still test that
iconv works with an invalid stream.
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.

1 participant