Skip to content

Fix tests with non-GNU iconv #16840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ext/iconv/tests/bug48147.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Bug #48147 (iconv with //IGNORE cuts the string)
--EXTENSIONS--
iconv
--SKIPIF--
<?php
// POSIX 2024 standardizes "//IGNORE", but does NOT say that
// it should ignore invalid input sequences, only untranslatable
// ones. The GNU implementations have however historically skipped
// invalid input sequences when it is used.
if (ICONV_IMPL != "libiconv" && ICONV_IMPL != "glibc") {
die("skip iconv will not //IGNORE invalid input sequences");
}
?>
--FILE--
<?php
$text = "aa\xC3\xC3\xC3\xB8aa";
Expand Down
11 changes: 11 additions & 0 deletions ext/iconv/tests/bug52211.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
--TEST--
Bug #52211 (iconv() returns part of string on error)
--SKIPIF--
<?php
// The two GNU iconvs (glibc and libiconv) fail if the input sequence
// cannot be converted to the target charset, but most others
// (including musl, FreeBSD, NetBSD, and Solaris) do not. POSIX says
// that "iconv() shall perform an implementation-defined conversion on
// the character," so this is likely to remain a GNUism.
if (ICONV_IMPL != "libiconv" && ICONV_IMPL != "glibc") {
die("skip iconv impl may not fail on unconvertable sequences");
}
?>
--EXTENSIONS--
iconv
--FILE--
Expand Down
6 changes: 3 additions & 3 deletions ext/iconv/tests/bug76249.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions ext/iconv/tests/eucjp2iso2022jp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
EUC-JP to ISO-2022-JP
--EXTENSIONS--
iconv
--SKIPIF--
<?php
// ISO-2022-JP is a stateful encoding, so the right answer is not
// unique. In particular, musl (type "unknown") is known to have an
// inefficient encoding for it that does not agree with the expected
// output below.
if (ICONV_IMPL == "unknown") {
die("skip byte-comparison of stateful encoding with unknown iconv");
}
?>
--INI--
error_reporting=2039
--FILE--
Expand Down
10 changes: 10 additions & 0 deletions ext/iconv/tests/iconv_mime_encode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
iconv_mime_encode()
--EXTENSIONS--
iconv
--SKIPIF--
<?php
// ISO-2022-JP is a stateful encoding, so the right answer is not
// unique. In particular, musl (type "unknown") is known to have an
// inefficient encoding for it that does not agree with the expected
// output below.
if (ICONV_IMPL == "unknown") {
die("skip byte-comparison of stateful encoding with unknown iconv");
}
?>
--INI--
iconv.internal_charset=iso-8859-1
--FILE--
Expand Down