diff --git a/netwerk/mime/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/nsMIMEHeaderParamImpl.cpp index 4bc5414a648..8490f63a1cb 100644 --- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp @@ -619,7 +619,13 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue, // skip over whitespace, ';', whitespace. increment_str: while (nsCRT::IsAsciiSpace(*str)) ++str; - if (*str == ';') ++str; + if (*str == ';') { + ++str; + } else { + // stop processing the header field; either we are done or the + // separator was missing + break; + } while (nsCRT::IsAsciiSpace(*str)) ++str; } diff --git a/netwerk/test/unit/test_MIME_params.js b/netwerk/test/unit/test_MIME_params.js index 8fee955b6b6..22e63730c5e 100644 --- a/netwerk/test/unit/test_MIME_params.js +++ b/netwerk/test/unit/test_MIME_params.js @@ -112,7 +112,7 @@ var tests = [ // First series, only please, and don't slurp up higher elements (*2 in this // case) from later series into earlier one (invalid; error recovery) - ["attachment; filename=basic; filename*0*=UTF-8''multi\r\n" + ["attachment; filename=basic; filename*0*=UTF-8''multi;\r\n" + " filename*1=line;\r\n" + " filename*0*=UTF-8''wrong;\r\n" + " filename*1=bad;\r\n" @@ -397,9 +397,16 @@ var tests = [ "attachment", "basic"], // Bug 732369: Content-Disposition parser does not require presence of ";" between params + // optimally, this would not even return the disposition type "attachment" ["attachment; extension=bla filename=foo", + "attachment", Cr.NS_ERROR_INVALID_ARG], + + ["attachment; filename=foo extension=bla", "attachment", "foo"], + + ["attachment filename=foo", + "attachment", Cr.NS_ERROR_INVALID_ARG], ]; var rfc5987paramtests = [