Backed out changeset 4cadb299e5ef (bug 588389) to fix orange.
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 08 Apr 2011 14:07:07 -0700
changeset 67726 2982dbd4d61bf93f9aeba589516ea441a12fd435
parent 67725 ab290352e31698ddee5f352031157e6edb86edba
child 67727 b980d0cf984767de8eba4a7e82c57195d44bfe60
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs588389
milestone2.2a1pre
backs out4cadb299e5efac8841181a6547abd4f11cc0e66b
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
Backed out changeset 4cadb299e5ef (bug 588389) to fix orange.
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/test/unit/test_bug588389.js
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -121,34 +121,16 @@ nsMIMEHeaderParamImpl::GetParameter(cons
 
     if (aTryLocaleCharset && !NS_IsNativeUTF8()) 
       return NS_CopyNativeToUnicode(str1, aResult);
 
     CopyASCIItoUTF16(str1, aResult);
     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,
 //                            char **charset, char **language)
 //
 // The format of these header lines  is
 // <token> [ ';' <token> '=' <token-or-quoted-string> ]*
 NS_IMETHODIMP 
@@ -229,33 +211,29 @@ nsMIMEHeaderParamImpl::GetParameterInter
       ;
     tokenEnd = str;
 
     // Skip over whitespace, '=', and whitespace
     while (nsCRT::IsAsciiSpace(*str)) ++str;
     if (*str == '=') ++str;
     while (nsCRT::IsAsciiSpace(*str)) ++str;
 
-    PRBool needUnquote = PR_FALSE;
-    
     if (*str != '"')
     {
       // The value is a token, not a quoted string.
       valueStart = str;
       for (valueEnd = str;
            *valueEnd && !nsCRT::IsAsciiSpace (*valueEnd) && *valueEnd != ';';
            valueEnd++)
         ;
       str = valueEnd;
     }
     else
     {
-      // The value is a quoted string.
-      needUnquote = PR_TRUE;
-      
+      // The value is a quoted string. 
       ++str;
       valueStart = str;
       for (valueEnd = str; *valueEnd; ++valueEnd)
       {
         if (*valueEnd == '\\')
           ++valueEnd;
         else if (*valueEnd == '"')
           break;
@@ -268,24 +246,18 @@ nsMIMEHeaderParamImpl::GetParameterInter
     // If so, copy it and return.
     if (tokenEnd - tokenStart == paramLen &&
         !nsCRT::strncasecmp(tokenStart, aParamName, paramLen))
     {
       // if the parameter spans across multiple lines we have to strip out the
       //     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
     else if (tokenEnd - tokenStart > paramLen &&
              !nsCRT::strncasecmp(tokenStart, aParamName, paramLen) &&
              *(tokenStart + paramLen) == '*')
     {
       const char *cp = tokenStart + paramLen + 1; // 1st char pass '*'
deleted file mode 100644
--- a/netwerk/test/unit/test_bug588389.js
+++ /dev/null
@@ -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]);
-  }
-}
-