Bug 783502: MIME parsing fix. r=jcduell, a=akeybl
authorjulian.reschke@gmx.de
Thu, 20 Sep 2012 16:52:26 -0400
changeset 81994 b46718d660187b70da4ac8448dafb39d5ad1eacf
parent 81993 5c74f60500ecd7480185cabc63ea9b3c8cbc3706
child 81995 62ad5b34715dd0a50b38eba04337083e61dc02fe
push id270
push userjduell@mozilla.com
push dateThu, 20 Sep 2012 20:54:15 +0000
reviewersjcduell, akeybl
bugs783502
milestone10.0.8esrpre
Bug 783502: MIME parsing fix. r=jcduell, a=akeybl
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/test/unit/test_MIME_params.js
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -296,19 +296,18 @@ nsMIMEHeaderParamImpl::DoParameterIntern
     }
     else
     {
       // The value is a quoted string.
       needUnquote = true;
       
       ++str;
       valueStart = str;
-      for (valueEnd = str; *valueEnd; ++valueEnd)
-      {
-        if (*valueEnd == '\\')
+      for (valueEnd = str; *valueEnd; ++valueEnd) {
+        if (*valueEnd == '\\' && *(valueEnd + 1))
           ++valueEnd;
         else if (*valueEnd == '"')
           break;
       }
       str = valueEnd;
       // *valueEnd != null means that *valueEnd is quote character.
       if (*valueEnd)
         str++;
--- a/netwerk/test/unit/test_MIME_params.js
+++ b/netwerk/test/unit/test_MIME_params.js
@@ -296,16 +296,21 @@ var tests = [
 
   ["attachment; filename*=\"a%20b\"", 
    "attachment", "a b"],
 
   // Bug 717121: crash nsMIMEHeaderParamImpl::DoParameterInternal
 
   ["attachment; filename=\"", 
    "attachment", ""], 
+
+  // Bug 783502 - xpcshell test netwerk/test/unit/test_MIME_params.js fails on AddressSanitizer
+
+  ['attachment; filename="\\b\\a\\',
+   'attachment', 'ba\\'],
 ];
 
 function do_tests(whichRFC)
 {
   var mhp = Components.classes["@mozilla.org/network/mime-hdrparam;1"]
                       .getService(Components.interfaces.nsIMIMEHeaderParam);
 
   var unused = { value : null };