From b4a77c0066619f15cc17e08b072cfd65f774e44e Mon Sep 17 00:00:00 2001 From: xhe Date: Fri, 28 Dec 2018 07:35:36 +0800 Subject: poparser: charset str should stop at escape chars as we will pass raw strings directly at the first stage, we may meet an escaped '\n', e.g. "\\n". because, there's no '\\' in charset strings, we can use '\\' as a terminator to avoid taking useless parts. useless parts will cause a unsupported_charset error. --- src/poparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/poparser.c b/src/poparser.c index 831efa3..e512db7 100644 --- a/src/poparser.c +++ b/src/poparser.c @@ -52,7 +52,7 @@ static inline enum po_error poparser_feed_hdr(struct po_parser *p, char* msg) { char *x, *y; if (p->first && msg) { if ((x = strstr(msg, "charset="))) { - for (y = x; *y && !isspace(*y); y++); + for (y = x; *y && *y != '\\' && !isspace(*y); y++); if ((uintptr_t)(y-x-7) > sizeof(p->hdr.charset)) return -po_unsupported_charset; -- cgit v1.2.1