Fix charset transcoding issue for non-reversible codepoints

* src/url.c: Check iconv() against 0, not -1

On some libiconv implementations, unknown codepoints become
encoded as ?, e.g. when converting a non-ascii codepoint to ASCII.
This results in ambigious file names which also fails our tests.
This commit is contained in:
Tim Rühsen 2017-04-16 19:55:14 +02:00
parent fc2f4233ed
commit 92bfe2a2e4
2 changed files with 45 additions and 40 deletions

2
gnulib

@ -1 +1 @@
Subproject commit 683b6078961f10905baba598c469402ed0133425
Subproject commit f497bc109ac365359ce499aeaef74f39c7e4e8c7

View File

@ -1579,8 +1579,9 @@ convert_fname (char *fname)
for (;;)
{
if (iconv (cd, (ICONV_CONST char **) &fname, &inlen, &s, &outlen) != (size_t)(-1)
&& iconv (cd, NULL, NULL, &s, &outlen) != (size_t)(-1))
errno = 0;
if (iconv (cd, (ICONV_CONST char **) &fname, &inlen, &s, &outlen) == 0
&& iconv (cd, NULL, NULL, &s, &outlen) == 0)
{
*(converted_fname + len - outlen - done) = '\0';
iconv_close (cd);
@ -1591,10 +1592,14 @@ convert_fname (char *fname)
}
/* Incomplete or invalid multibyte sequence */
if (errno == EINVAL || errno == EILSEQ)
if (errno == EINVAL || errno == EILSEQ || errno == 0)
{
if (errno)
logprintf (LOG_VERBOSE,
_ ("Incomplete or invalid multibyte sequence encountered\n"));
else
logprintf (LOG_VERBOSE,
_ ("Unconvertable multibyte sequence encountered\n"));
xfree (converted_fname);
converted_fname = (char *) orig_fname;
break;