From b90438bef61b6cce6b5509282f6c8bafd3135027 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Tue, 28 Nov 2017 08:55:39 +0100 Subject: [PATCH] src: fix for multiple filename in a single mime part line Signed-off-by: Janos SUTO --- src/parser_utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/parser_utils.c b/src/parser_utils.c index b09d6500..377b7518 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -791,6 +791,11 @@ void extractNameFromHeaderLine(char *s, char *name, char *resultbuf){ * * foo: bar; title*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates * + * Odd one having two filename definitions, and having a semicolon (;) in the filename: + * + * filename*=utf-8''P;LAN%20Holden%204.docx;filename="P;LAN Holden 4.docx"* + * + * */ p += strlen(name); @@ -801,6 +806,12 @@ void extractNameFromHeaderLine(char *s, char *name, char *resultbuf){ p = strchr(p, '='); if(p){ p++; + + // If the line has the 'name' more than once, then truncate the subsequent parts, ie. + // utf-8''P;LAN%20Holden%204.docx;filename="P;LAN Holden 4.docx" ==> utf-8''P;LAN%20Holden%204.docx + q = strstr(p, name); + if(q) *q = '\0'; + q = strrchr(p, ';'); if(q) *q = '\0'; q = strrchr(p, '"');