From 9098d15c3de81818fc8a3892c8ee09487165e92f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 16 Nov 2024 21:12:40 -0500 Subject: [PATCH 1/5] ext/iconv/tests/bug52211.phpt: skip for non-GNU iconv implementations This test ensures that iconv() will not return part of the string if it encounters an error, but the particular error it wants to cause is not portable. When the input sequence is not representable in the output charset, POSIX says that "iconv() shall perform an implementation-defined conversion on the character" rather than fail. As far as I know, the only two implementations that go against this recommendation (and return the error that this test is expecting) are GNU libiconv and glibc. This commit adds a SKIPIF check for the two GNU implementations to ensure that an error is actually encountered during this test. --- ext/iconv/tests/bug52211.phpt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ext/iconv/tests/bug52211.phpt b/ext/iconv/tests/bug52211.phpt index f213c764de815..a68580447374d 100644 --- a/ext/iconv/tests/bug52211.phpt +++ b/ext/iconv/tests/bug52211.phpt @@ -1,5 +1,16 @@ --TEST-- Bug #52211 (iconv() returns part of string on error) +--SKIPIF-- + --EXTENSIONS-- iconv --FILE-- From 2f97c3ede8e43dadebd6a9e58348eca8c3fcaa06 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 16 Nov 2024 21:27:58 -0500 Subject: [PATCH 2/5] ext/iconv/tests/bug76249.phpt: drop //IGNORE suffix This test performs a conversion from UCS-2 to UTF-8 using iconv and stream filters, with the suffix "//IGNORE" being added to the target charset. This magic //IGNORE string was recently standardized in POSIX 2024, but it is not yet portable: musl for example will simply fail when it encounters //IGNORE in what is supposed to be a charset name. Fortunately, we do not need to think too hard about the general problem here: the input is "abc", which has no un-translatable sequences. We can simply drop the "//IGNORE". --- ext/iconv/tests/bug76249.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/iconv/tests/bug76249.phpt b/ext/iconv/tests/bug76249.phpt index 37608ccc04470..39e549d7a7f75 100644 --- a/ext/iconv/tests/bug76249.phpt +++ b/ext/iconv/tests/bug76249.phpt @@ -7,13 +7,13 @@ iconv $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', STREAM_FILTER_READ, [])) { + stream_filter_append($fh, 'convert.iconv.ucs-2/utf-8', 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 +Warning: stream_get_contents(): iconv stream filter ("ucs-2"=>"utf%A8"): invalid multibyte sequence in %sbug76249.php on line %d string(0) "" DONE From ade7f6fdf1bf953418299f7f21b23bf9d1a22690 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 16 Nov 2024 22:21:00 -0500 Subject: [PATCH 3/5] ext/iconv/tests/bug48147.phpt: skip for non-GNU iconv implementations This test meaningfully uses the //IGNORE charset suffix that was was a GNU/Solaris extension but is now standardized in POSIX 2024. The way //IGNORE is used, however, is non-standard: POSIX says that //IGNORE will cause untranslatable sequences to be skipped, but this test is expecting it to skip input sequences that are invalid rather than unexpressible in the target charset. That behavior is specific to the two GNU implementations (and was always non-conforming...), so we add a SKIPIF block to ensure that one of the GNU implementations is used. --- ext/iconv/tests/bug48147.phpt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/iconv/tests/bug48147.phpt b/ext/iconv/tests/bug48147.phpt index ce304eecfb3c7..bce73893350a4 100644 --- a/ext/iconv/tests/bug48147.phpt +++ b/ext/iconv/tests/bug48147.phpt @@ -2,6 +2,16 @@ Bug #48147 (iconv with //IGNORE cuts the string) --EXTENSIONS-- iconv +--SKIPIF-- + --FILE-- Date: Sat, 16 Nov 2024 22:55:07 -0500 Subject: [PATCH 4/5] ext/iconv/tests/eucjp2iso2022jp.phpt: skip for "unknown" iconv This test does a byte comparison of the expected ISO-2022-JP encoding with the result of iconv(). The ISO-2022-JP encoding, however, is stateful; there are many ways to arrive at a correct answer. Musl is known to have an inefficient encoding that causes it to fail this test, so we add a SKIPIF for the "unknown" iconv implementation that musl has. Nothing is wrong here per se, but to support the musl output (and that of other iconvs), an expert would need to verify it. --- ext/iconv/tests/eucjp2iso2022jp.phpt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/iconv/tests/eucjp2iso2022jp.phpt b/ext/iconv/tests/eucjp2iso2022jp.phpt index 6c1a8ec1214bc..c3260c370f08f 100644 --- a/ext/iconv/tests/eucjp2iso2022jp.phpt +++ b/ext/iconv/tests/eucjp2iso2022jp.phpt @@ -2,6 +2,16 @@ EUC-JP to ISO-2022-JP --EXTENSIONS-- iconv +--SKIPIF-- + --INI-- error_reporting=2039 --FILE-- From f25e0e5b2062029f3bb4ea0d20bd7aaa8c8b3efa Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 16 Nov 2024 23:13:42 -0500 Subject: [PATCH 5/5] ext/iconv/tests/iconv_mime_encode.phpt: skip for "unknown" iconv This test checks the output of iconv_mime_encode() with a target charset of ISO-2022-JP. That charset is stateful, though, and there are many ways to arrive at a correct answer. Musl has an inefficient encoding of it that causes this to fail because the actual output differs from (and is much longer than) the expected output. We add a SKIPIF for the "unknown" iconv implementation that musl has. --- ext/iconv/tests/iconv_mime_encode.phpt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/iconv/tests/iconv_mime_encode.phpt b/ext/iconv/tests/iconv_mime_encode.phpt index e055f53b016ac..c6f41c56ad908 100644 --- a/ext/iconv/tests/iconv_mime_encode.phpt +++ b/ext/iconv/tests/iconv_mime_encode.phpt @@ -2,6 +2,16 @@ iconv_mime_encode() --EXTENSIONS-- iconv +--SKIPIF-- + --INI-- iconv.internal_charset=iso-8859-1 --FILE--