forked from github/server
Parser fallback to latin1 when detecting invalid utf-8
This commit is contained in:
parent
2fe4261c70
commit
55704cfce8
|
@ -173,8 +173,15 @@ char *parse_token(const char **str, char *lbuf, size_t buflen)
|
||||||
else {
|
else {
|
||||||
int ret = unicode_utf8_decode(&wc, ctoken, &len);
|
int ret = unicode_utf8_decode(&wc, ctoken, &len);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
log_warning("illegal character sequence in UTF8 string: %s\n", ctoken);
|
log_info("falling back to ISO-8859-1: %s\n", cstart);
|
||||||
break;
|
if (cursor - buflen < lbuf - 2) {
|
||||||
|
size_t inlen = 1;
|
||||||
|
len = 2;
|
||||||
|
unicode_latin1_to_utf8(cursor, &len, ctoken, &inlen);
|
||||||
|
cursor += len;
|
||||||
|
ctoken += inlen;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (escape) {
|
if (escape) {
|
||||||
|
|
Loading…
Reference in New Issue