author | Julian Reschke <julian.reschke@gmx.de> |
Fri, 14 Oct 2011 11:29:13 +0200 | |
changeset 78731 | 4b87afed1d1c92f2740d6b5965b2c47a69c1b3a1 |
parent 78730 | 6715771c1d9a32da64293eebccd6fcf9a07eaae0 |
child 78732 | 61dd23c012eef276495b8956cc8747e3ae4b7abd |
push id | 21329 |
push user | eakhgari@mozilla.com |
push date | Fri, 14 Oct 2011 14:37:50 +0000 |
treeherder | mozilla-central@349f3d4b2d87 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 692574 |
milestone | 10.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
|
netwerk/mime/nsMIMEHeaderParamImpl.cpp | file | annotate | diff | comparison | revisions | |
netwerk/test/unit/test_MIME_params.js | file | annotate | diff | comparison | revisions |
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp +++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp @@ -365,44 +365,37 @@ nsMIMEHeaderParamImpl::DoParameterIntern goto increment_str; } } // look for single quotation mark(') const char *sQuote1 = PL_strchr(valueStart, 0x27); const char *sQuote2 = (char *) (sQuote1 ? PL_strchr(sQuote1 + 1, 0x27) : nsnull); // Two single quotation marks must be present even in - // absence of charset and lang. - if (!sQuote1 || !sQuote2) - NS_WARNING("Mandatory two single quotes are missing in header parameter\n"); + // absence of charset and lang. + if (!sQuote1 || !sQuote2) { + // log the warning and skip to next parameter + NS_WARNING("Mandatory two single quotes are missing in header parameter, parameter ignored\n"); + goto increment_str; + } + if (aCharset && sQuote1 > valueStart && sQuote1 < valueEnd) { *aCharset = (char *) nsMemory::Clone(valueStart, sQuote1 - valueStart + 1); if (*aCharset) *(*aCharset + (sQuote1 - valueStart)) = 0; } - if (aLang && sQuote1 && sQuote2 && sQuote2 > sQuote1 + 1 && - sQuote2 < valueEnd) + if (aLang && sQuote2 > sQuote1 + 1 && sQuote2 < valueEnd) { *aLang = (char *) nsMemory::Clone(sQuote1 + 1, sQuote2 - (sQuote1 + 1) + 1); if (*aLang) *(*aLang + (sQuote2 - (sQuote1 + 1))) = 0; } - - // Be generous and handle gracefully when required - // single quotes are absent. - if (sQuote1) - { - if(!sQuote2) - sQuote2 = sQuote1; - } - else - sQuote2 = valueStart - 1; - - if (sQuote2 && sQuote2 + 1 < valueEnd) + + if (sQuote2 + 1 < valueEnd) { if (*aResult) { // caseA value already read, or caseC/D value already read // but we're now reading caseB: either way, drop old value nsMemory::Free(*aResult); haveCaseAValue = false; }
--- a/netwerk/test/unit/test_MIME_params.js +++ b/netwerk/test/unit/test_MIME_params.js @@ -246,16 +246,31 @@ var tests = [ // the actual bug, without 2231/5987 encoding ["attachment; filename X", "attachment", Cr.NS_ERROR_INVALID_ARG], // sanity check with WS on both sides ["attachment; filename = foo-A.html", "attachment", "foo-A.html"], + + // Bug 692574: RFC2231/5987 decoding should not tolerate missing single + // quotes + + // one missing + ["attachment; filename*=UTF-8'foo-%41.html", + "attachment", Cr.NS_ERROR_INVALID_ARG], + + // both missing + ["attachment; filename*=foo-%41.html", + "attachment", Cr.NS_ERROR_INVALID_ARG], + + // make sure fallback works + ["attachment; filename*=UTF-8'foo-%41.html; filename=bar.html", + "attachment", "bar.html"], ]; function do_tests(whichRFC) { var mhp = Components.classes["@mozilla.org/network/mime-hdrparam;1"] .getService(Components.interfaces.nsIMIMEHeaderParam); var unused = { value : null };