[php-src] master: Merge branch 'PHP-8.5'

Gina Peter Banyard <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Gina Peter Banyard (Girgias)
Date: 2026-07-08T15:42:51+01:00

Commit: https://github.com/php/php-src/commit/476da42405051c35cb6ca55ce66ed8e51a8e1a2c
Raw diff: https://github.com/php/php-src/commit/476da42405051c35cb6ca55ce66ed8e51a8e1a2c.diff

Merge branch 'PHP-8.5'

* PHP-8.5:
  ext/iconv/tests/bug52211.phpt: use per-iconv charset names (#22543)
  ext/iconv/tests/bug76249.phpt: fallback for non-GNU iconv() (#22552)

Changed paths:
  M  ext/iconv/tests/bug52211.phpt
  M  ext/iconv/tests/bug76249.phpt


Diff:

diff --git a/ext/iconv/tests/bug52211.phpt b/ext/iconv/tests/bug52211.phpt
index 155fad853485..7832cbeadd00 100644
--- a/ext/iconv/tests/bug52211.phpt
+++ b/ext/iconv/tests/bug52211.phpt
@@ -11,8 +11,22 @@ if (PHP_OS_FAMILY === 'Solaris') {
 --FILE--
 <?php
 
+// According to POSIX 2024, the to/from charset names are
+// implementation-defined. To keep this test true to its original
+// purpose, we retain the charsets used in bug 52211, but only when
+// the implementation is known to support them. Otherwise we default
+// both to ASCII, which should be supported everywhere (in particular
+// on musl) yet still considers the input invalid.
+$from_charset = "ASCII";
+$to_charset = "ASCII";
+
+if (ICONV_IMPL == "libiconv" || ICONV_IMPL == "glibc") {
+    $from_charset = "CP850";
+    $to_charset = "ISO-8859-1";
+}
+
 $str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
-$str_iconv = iconv('CP850', 'ISO-8859-1', $str );
+$str_iconv = iconv($from_charset, $to_charset, $str );
 var_dump($str_iconv);
 
 ?>
diff --git a/ext/iconv/tests/bug76249.phpt b/ext/iconv/tests/bug76249.phpt
index 37608ccc0447..2fa9b8cc0500 100644
--- a/ext/iconv/tests/bug76249.phpt
+++ b/ext/iconv/tests/bug76249.phpt
@@ -4,16 +4,27 @@ Bug #76249 (stream filter convert.iconv leads to infinite loop on invalid sequen
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.