Backed out changeset 4cadb299e5ef (bug 588389) to fix orange.

--HG--
extra : rebase_source : 02d07a9b1e784a3c8538ccae54c43e8eb17468d6
This commit is contained in:
Boris Zbarsky 2011-04-08 14:07:07 -07:00
Родитель 17f44743ba
Коммит 1e9351c279
2 изменённых файлов: 3 добавлений и 64 удалений

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

@ -126,24 +126,6 @@ nsMIMEHeaderParamImpl::GetParameter(const nsACString& aHeaderVal,
return NS_OK;
}
// remove backslash-encoded sequences from quoted-strings
// modifies string in place, potentially shortening it
void RemoveQuotedStringEscapes(char *src)
{
char *dst = src;
for (char *c = src; *c; c += 1)
{
if (c[0] == '\\' && c[1])
{
// skip backslash if not at end
++c;
}
*dst++ = *c;
}
*dst = 0;
}
// moved almost verbatim from mimehdrs.cpp
// char *
// MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
@ -234,8 +216,6 @@ nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue,
if (*str == '=') ++str;
while (nsCRT::IsAsciiSpace(*str)) ++str;
PRBool needUnquote = PR_FALSE;
if (*str != '"')
{
// The value is a token, not a quoted string.
@ -248,9 +228,7 @@ nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue,
}
else
{
// The value is a quoted string.
needUnquote = PR_TRUE;
// The value is a quoted string.
++str;
valueStart = str;
for (valueEnd = str; *valueEnd; ++valueEnd)
@ -273,14 +251,8 @@ nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue,
// line continuation -- jht 4/29/98
nsCAutoString tempStr(valueStart, valueEnd - valueStart);
tempStr.StripChars("\r\n");
char *res = ToNewCString(tempStr);
NS_ENSURE_TRUE(*res, NS_ERROR_OUT_OF_MEMORY);
if (needUnquote)
RemoveQuotedStringEscapes(res);
*aResult = res;
*aResult = ToNewCString(tempStr);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
// keep going, we may find a RFC 2231 encoded alternative
}
// case B, C, and D

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

@ -1,33 +0,0 @@
/**
* Test for bug 588389: unescaping backslashes in quoted string parameters
*/
var BS = '\\';
var DQUOTE = '"';
var reference = [
[ // '\"', should be parsed as '"'
"Content-Disposition: attachment; foobar=" + DQUOTE + (BS + DQUOTE) + DQUOTE,
DQUOTE],
[ // 'a\"b', should be parsed as 'a"b'
"Content-Disposition: attachment; foobar=" + DQUOTE + 'a' + (BS + DQUOTE) + 'b' + DQUOTE,
'a' + DQUOTE + 'b'],
[ // '\x', should be parsed as 'x'
"Content-Disposition: attachment; foobar=" + DQUOTE + (BS + "x") + DQUOTE,
"x"],
];
function run_test() {
var mhp = Components.classes["@mozilla.org/network/mime-hdrparam;1"]
.getService(Components.interfaces.nsIMIMEHeaderParam);
var unused = { value : null };
for (var i = 0; i < reference.length; ++i) {
dump("Testing " + reference[i] + "\n");
do_check_eq(mhp.getParameter(reference[i][0], "foobar", "UTF-8", true, unused),
reference[i][1]);
}
}