зеркало из https://github.com/mozilla/gecko-dev.git
Bug 692574 - RFC2231/5987 decoding should not tolerate missing single quotes. r=bz
This commit is contained in:
Родитель
b1d63ad959
Коммит
07d0d35b47
|
@ -371,33 +371,26 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue,
|
|||
|
||||
// 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");
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -251,6 +251,21 @@ var tests = [
|
|||
// 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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче