Bug 704989: add workaround for broken Outlook Web APP (OWA) attachment handling (and specifically for it sending broken headers only to Firefox). r=bzbarsky

This commit is contained in:
julian.reschke@gmx.de 2011-11-28 07:40:08 -05:00
Родитель d64d08c89f
Коммит 14ebb50971
2 изменённых файлов: 37 добавлений и 23 удалений

Просмотреть файл

@ -370,34 +370,34 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue,
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) {
// 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;
}
// charset part is required
if (! (sQuote1 > valueStart && sQuote1 < valueEnd)) {
// log the warning and skip to next parameter
NS_WARNING("Mandatory charset part missing in header parameter, parameter ignored\n");
goto increment_str;
}
if (aCharset) {
// absence of charset and lang.
if (!sQuote1 || !sQuote2)
NS_WARNING("Mandatory two single quotes are missing in header parameter\n");
if (aCharset && sQuote1 > valueStart && sQuote1 < valueEnd)
{
*aCharset = (char *) nsMemory::Clone(valueStart, sQuote1 - valueStart + 1);
if (*aCharset)
*(*aCharset + (sQuote1 - valueStart)) = 0;
}
if (aLang && sQuote2 > sQuote1 + 1 && sQuote2 < valueEnd)
if (aLang && sQuote1 && sQuote2 && sQuote2 > sQuote1 + 1 &&
sQuote2 < valueEnd)
{
*aLang = (char *) nsMemory::Clone(sQuote1 + 1, sQuote2 - (sQuote1 + 1) + 1);
if (*aLang)
*(*aLang + (sQuote2 - (sQuote1 + 1))) = 0;
}
if (sQuote2 + 1 < valueEnd)
// 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 (*aResult)
{

Просмотреть файл

@ -262,7 +262,9 @@ var tests = [
// the actual bug
["attachment; filename*=''foo",
"attachment", Cr.NS_ERROR_INVALID_ARG],
"attachment", "foo"],
// previously with the fix for 692574:
// "attachment", Cr.NS_ERROR_INVALID_ARG],
// sanity check
["attachment; filename*=a''foo",
@ -273,15 +275,27 @@ var tests = [
// one missing
["attachment; filename*=UTF-8'foo-%41.html",
"attachment", Cr.NS_ERROR_INVALID_ARG],
"attachment", "foo-A.html"],
// previously with the fix for 692574:
// "attachment", Cr.NS_ERROR_INVALID_ARG],
// both missing
["attachment; filename*=foo-%41.html",
"attachment", Cr.NS_ERROR_INVALID_ARG],
"attachment","foo-A.html"],
// previously with the fix for 692574:
// "attachment", Cr.NS_ERROR_INVALID_ARG],
// make sure fallback works
["attachment; filename*=UTF-8'foo-%41.html; filename=bar.html",
"attachment", "bar.html"],
"attachment", "foo-A.html"],
// previously with the fix for 692574:
// "attachment", "bar.html"],
// Bug 704989: add workaround for broken Outlook Web App (OWA)
// attachment handling
["attachment; filename*=\"a%20b\"",
"attachment", "a b"],
];
function do_tests(whichRFC)