Commit 0b9644161c5 for php.net
commit 0b9644161c5ff23adda2ee28af86ae11307cbc2b
Author: Michael Orlitzky <michael@orlitzky.com>
Date: Wed Jul 8 10:41:21 2026 -0400
ext/iconv/tests/bug76249.phpt: fallback for non-GNU iconv() (#22552)
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 that are known to support it. POSIX specifies
its behavior, but leaves overall support optional.
diff --git a/ext/iconv/tests/bug76249.phpt b/ext/iconv/tests/bug76249.phpt
index 37608ccc044..2fa9b8cc050 100644
--- a/ext/iconv/tests/bug76249.phpt
+++ b/ext/iconv/tests/bug76249.phpt
@@ -4,16 +4,27 @@
iconv
--FILE--
<?php
+$ignore = "";
+if (ICONV_IMPL == "libiconv" || ICONV_IMPL == "glibc") {
+ // The original bug report uses "//IGNORE", and the bug itself
+ // involves the return value and errno from iconv(), so in the
+ // interest of fidelity we include the suffix on systems like the
+ // one where the bug was reported. On other systems however, the
+ // "//IGNORE" suffix may not be supported, and this is allowed by
+ // POSIX (musl in particular does not support it).
+ $ignore = "//IGNORE";
+}
+
$fh = fopen('php://memory', 'rw');
fwrite($fh, "abc");
rewind($fh);
-if (false === @stream_filter_append($fh, 'convert.iconv.ucs-2/utf8//IGNORE', STREAM_FILTER_READ, [])) {
- stream_filter_append($fh, 'convert.iconv.ucs-2/utf-8//IGNORE', STREAM_FILTER_READ, []);
+if (false === @stream_filter_append($fh, "convert.iconv.ucs-2/utf8{$ignore}", STREAM_FILTER_READ, [])) {
+ stream_filter_append($fh, "convert.iconv.ucs-2/utf-8{$ignore}", STREAM_FILTER_READ, []);
}
var_dump(stream_get_contents($fh));
?>
DONE
---EXPECTF--
-Warning: stream_get_contents(): iconv stream filter ("ucs-2"=>"utf%A8//IGNORE"): invalid multibyte sequence in %sbug76249.php on line %d
-string(0) ""
+--EXPECTREGEX--
+Warning: stream_get_contents\(\): iconv stream filter \("ucs-2"=>"utf-?8(\/\/IGNORE)?"\): invalid multibyte sequence in .*bug76249\.php on line \d+
+string\(0\) ""
DONE