Skip to content
Snippets Groups Projects
Commit 6f3b22e6 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Support non-quoted MIME Content-type boundary parameters (semicolon delimited)

This should fix issue #559, for example:
  Content-Type: multipart/alternative;
    boundary=mk3-ebfa33c1cd454cc2b1c618f5d74b41af; charset=UTF-8

We were assuming all boundary parameter values are quoted (apparently not
true, see https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1) - so support
non-quoted boundary values which also may have a semicolon delimiter.

Also, truncate any white-space from a boundary value (shouldn't be there per
RFC2046).
parent 33c0654d
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4248 passed
......@@ -411,6 +411,7 @@ static const char* mime_getpart(const char* buf, const char* content_type, const
char match2[128];
int match_len = 0;
int found = 0;
BOOL quoted_boundary = FALSE;
if(content_match != NULL) {
match_len = sprintf(match1, "%s;", content_match);
......@@ -432,11 +433,14 @@ static const char* mime_getpart(const char* buf, const char* content_type, const
if(p == NULL)
return NULL;
p += 9;
if(*p == '"')
if(*p == '"') {
p++;
quoted_boundary = TRUE;
}
SAFEPRINTF(boundary, "--%s", p);
if((p = strchr(boundary,'"')) != NULL)
if((p = strchr(boundary, quoted_boundary ? '"' : ';')) != NULL)
*p = 0;
truncsp(boundary); // RC2046: "NOT ending with white space"
txt = buf;
while((p = strstr(txt, boundary)) != NULL) {
txt = p+strlen(boundary);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment