From a5c14a463bee05cdb560c2bcd49760b4449f576a Mon Sep 17 00:00:00 2001 From: Alfred Peters Date: Mon, 29 Jan 2018 14:36:00 -0500 Subject: [PATCH] Bug 1412213 - Content-Type MIME-header - Skipping a parameter without an '='. r=mayhemer --- netwerk/mime/nsMIMEHeaderParamImpl.cpp | 4 +++- netwerk/test/unit/test_MIME_params.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/netwerk/mime/nsMIMEHeaderParamImpl.cpp b/netwerk/mime/nsMIMEHeaderParamImpl.cpp index 49eeae025f70..8d56d9e2a2fe 100644 --- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp @@ -470,10 +470,12 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue, 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 != '"') { diff --git a/netwerk/test/unit/test_MIME_params.js b/netwerk/test/unit/test_MIME_params.js index 882b142d5d5b..15dc2bb85d7f 100644 --- a/netwerk/test/unit/test_MIME_params.js +++ b/netwerk/test/unit/test_MIME_params.js @@ -432,6 +432,14 @@ var tests = [ // 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 = [