From: David Kalnischkies Date: Tue, 8 Sep 2009 07:47:12 +0000 (+0200) Subject: replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208) X-Git-Tag: 0.7.24~4^2~16 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/1f99b6d338186efe80e314268db44600d3c94a1e replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208) instead of ignoring the returncode and truncating the string on error --- diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 1683868c8..4c05f2df8 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -67,9 +67,20 @@ bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest) outbuf = new char[insize+1]; outptr = outbuf; - iconv(cd, &inptr, &insize, &outptr, &outsize); - *outptr = '\0'; + while (insize != 0) + { + size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize); + if (err == (size_t)(-1)) + { + insize--; + outsize++; + inptr++; + *outptr = '?'; + outptr++; + } + } + *outptr = '\0'; *dest = outbuf; delete[] outbuf; diff --git a/debian/changelog b/debian/changelog index 349c95038..34691b1fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ apt (0.7.24) UNRELEASED; urgency=low - simplify the makefiles needed for po4a manpages * apt-pkg/contrib/configuration.cc: - add a helper to easily get a vector of strings from the config + * apt-pkg/contrib/strutl.cc: + - replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208) -- David Kalnischkies Fri, 28 Aug 2009 09:40:08 +0200