[php-src] PR #16840: Fix tests with non-GNU iconv
| From: | orlitzky | Date: | Sun, 17 Nov 2024 14:55:11 +0000 |
| Subject: | [php-src] PR #16840: Fix tests with non-GNU iconv | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29675@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16840
Author: orlitzky
Get the iconv test suite passing with musl. This fixes some of https://github.com/php/php-src/issues/13696
Many of these issues relate to the
//IGNORE suffix that can be appended to the target
charset during conversion. This //IGNORE was [recently standardized in POSIX
2024](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/iconv.html), but there
are still some pitfalls:
* The standard says that //IGNORE will ignore untranslatable sequences (valid input
sequences that cannot be represented in the target charset), but sequences that are a priori invalid
should instead cause an EILSEQ -- even in earlier versions of the standard.
* The two GNU implementations have always ignored that, and have returned an EILSEQ for
invalid input sequences. Their //IGNORE allows these errors to be ignored. In other
words, the two GNU implementations have never conformed to POSIX.
* Other implementations may conform to POSIX, but not the 2024 version yet. In particular, musl
follows the earlier standards and will e.g. replace untranslatable sequences by a *
rather than fail. But it does not yet implement //IGNORE, and will simply crash if it
encounters //IGNORE in the charset name.
So, what is done here:
* Two of our tests rely on the non-standard (GNU) illegal input sequence //IGNORE
behavior. These get SKIPIFs.
* One test uses //IGNORE, but it has no effect on the output. Here the
//IGNORE was simply dropped.
* Two ISO-2022-JP tests are looking for GNU output, but that encoding is stateful and there is no
single correct answer. The musl answer is different. Rather than whitelist the GNU implementations
here, I've blacklisted "unknown" implementations, which includes musl. (I don't
see a good way to fix these tests otherwise.)
* I've actually removed the //IGNORE workaround in PHP's iconv function. It
does not and cannot be made to do the right thing. This was added in https://bugs.php.net/bug.php?id=48147 but it
assumes that iconv() will be "broken" in a very specific and unrealistic way. The commit
message explains in more detail.
@petk @arnaud-lb