Bug 1412213 - Content-Type MIME-header - Skipping a parameter without an '='. r=mayhemer
authorAlfred Peters <infofrommozilla@justmail.de>
Mon, 29 Jan 2018 14:36:00 -0500
changeset 401554 bc8174e0c380
parent 401553 03b01c35b207
child 401555 97c9705b1be2
push id33347
push userarchaeopteryx@coole-files.de
push dateTue, 30 Jan 2018 22:28:09 +0000
treeherdermozilla-central@217fc14405e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1412213
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1412213 - Content-Type MIME-header - Skipping a parameter without an '='. r=mayhemer
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/test/unit/test_MIME_params.js
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -465,20 +465,22 @@ nsMIMEHeaderParamImpl::DoParameterIntern
 
     int32_t nameLen = nameEnd - nameStart;
 
     // Skip over whitespace, '=', and whitespace
     while (nsCRT::IsAsciiSpace(*str)) ++str;
     if (!*str) {
       break;
     }
-    if (*str++ != '=') {
+    if (*str != '=') {
       // don't accept parameters without "="
       goto increment_str;
     }
+    // Skip over '=' only if it was actually there
+    str++;
     while (nsCRT::IsAsciiSpace(*str)) ++str;
 
     if (*str != '"') {
       // The value is a token, not a quoted string.
       valueStart = str;
       for (valueEnd = str;
            *valueEnd && !nsCRT::IsAsciiSpace (*valueEnd) && *valueEnd != ';';
            valueEnd++)
--- a/netwerk/test/unit/test_MIME_params.js
+++ b/netwerk/test/unit/test_MIME_params.js
@@ -427,16 +427,24 @@ var tests = [
    "attachment", "bar"], 
 
   ["attachment; filename*=UTF-8''foo%; filename=bar", 
    "attachment", "bar"], 
 
   // Bug 783502 - xpcshell test netwerk/test/unit/test_MIME_params.js fails on AddressSanitizer
   ['attachment; filename="\\b\\a\\', 
    "attachment", "ba\\"], 
+
+  // Bug 1412213 - do continue to parse, behind an empty parameter
+  ['attachment; ; filename=foo',
+   "attachment", "foo"],
+
+  // Bug 1412213 - do continue to parse, behind a parameter w/o =
+  ['attachment; badparameter; filename=foo',
+   "attachment", "foo"],
 ];
 
 var rfc5987paramtests = [
   [ // basic test
     "UTF-8'language'value", "value", "language", Cr.NS_OK ],
   [ // percent decoding
     "UTF-8''1%202", "1 2", "", Cr.NS_OK ],
   [ // UTF-8