Skip to content

Commit 9079d61

Browse files
committed
ext/iconv/tests/bug48147.phpt: rename and repurpose
This test ensures that iconv() with //IGNORE will return part of the translated string when it is given invalid inputs. POSIX and the PHP documentation however agree that an error should be returned in that case: the test is making sure that we get the wrong answer. PHP's iconv has recently been updated to agree with the standard and docs. As a result, this test fails, but that's OK -- it should. The history of iconv in PHP is convoluted, so rather than just update the expected output here, I think it's best to rename the test and sever its ties to bug 48147. Referencing that bug at this point can only cause confusion.
1 parent 0535da4 commit 9079d61

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

ext/iconv/tests/bug48147.phpt

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
iconv with //IGNORE should not ignore invalid input sequences
3+
--EXTENSIONS--
4+
iconv
5+
--SKIPIF--
6+
<?php
7+
// POSIX 2024 standardizes "//IGNORE", but some implementations (like musl)
8+
// do not support it yet. If iconv() doesn't understand "//IGNORE", the
9+
// tests below will still fail, but you'll get an error message about
10+
// finding an unexpected string in your encoding name rather than the
11+
// expected illegal-sequence error.
12+
if (ICONV_IMPL == "unknown") {
13+
die("skip iconv implementation may not understand //IGNORE");
14+
}
15+
?>
16+
--FILE--
17+
<?php
18+
$text = "aa\xC3\xC3\xC3\xB8aa";
19+
var_dump(iconv("UTF-8", "UTF-8", $text));
20+
var_dump(iconv("UTF-8", "UTF-8//IGNORE", $text));
21+
// only invalid
22+
var_dump(iconv("UTF-8", "UTF-8//IGNORE", "\xC3"));
23+
// start invalid
24+
var_dump(iconv("UTF-8", "UTF-8//IGNORE", "\xC3\xC3\xC3\xB8aa"));
25+
// finish invalid
26+
var_dump(iconv("UTF-8", "UTF-8//IGNORE", "aa\xC3\xC3\xC3"));
27+
?>
28+
--EXPECTF--
29+
Notice: iconv(): Detected an illegal character in input string in %s on line %d
30+
bool(false)
31+
32+
Notice: iconv(): Detected an illegal character in input string in %s on line %d
33+
bool(false)
34+
35+
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
36+
bool(false)
37+
38+
Notice: iconv(): Detected an illegal character in input string in %s on line %d
39+
bool(false)
40+
41+
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
42+
bool(false)

0 commit comments

Comments
 (0)