Bug 1023285 - Don't pass HEADER_OPTION_ALLOW_RAW in parseHeadersWithArray(). r=rkent a=jorgk
authorJorg K <mozilla@jorgk.com>
Wed, 13 Jul 2016 21:31:17 +0200
changeset 25145 117e0210d6368738c19dab3ed0ca68edaf4be87e
parent 25144 36a30cf1c5ef29bccfd46966dd40430986199f1c
child 25146 d27fd60554341c443841286a115b7c0fe39e37f9
push id1688
push userclokep@gmail.com
push dateMon, 01 Aug 2016 16:45:40 +0000
treeherdercomm-beta@9abd7cedb2af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, jorgk
bugs1023285
Bug 1023285 - Don't pass HEADER_OPTION_ALLOW_RAW in parseHeadersWithArray(). r=rkent a=jorgk
mailnews/mime/public/nsIMsgHeaderParser.idl
mailnews/mime/src/mimeJSComponents.js
--- a/mailnews/mime/public/nsIMsgHeaderParser.idl
+++ b/mailnews/mime/public/nsIMsgHeaderParser.idl
@@ -173,16 +173,19 @@ interface nsIMsgHeaderParser : nsISuppor
    * Return an array of structured mailbox objects for the given display name
    * string.
    *
    * The string is expected to be a comma-separated sequence of strings that
    * would be produced by msgIAddressObject::toString(). For example, the string
    * "Bond, James <agent007@mi5.invalid>" would produce one address object,
    * while the string "webmaster@nowhere.invalid, child@nowhere.invalid" would
    * produce two address objects.
+   *
+   * Note that the input string is RFC 2231 and RFC 2047 decoded but no UTF-8
+   * decoding takes place.
    */
   void makeFromDisplayAddress(in AString aDisplayAddresses,
                               [optional] out unsigned long count,
                               [retval, array, size_is(count)] out msgIAddressObject addresses);
 
   [deprecated] void parseHeadersWithArray(in wstring aLine,
                              [array, size_is(count)] out wstring aEmailAddresses,
                              [array, size_is(count)] out wstring aNames,
--- a/mailnews/mime/src/mimeJSComponents.js
+++ b/mailnews/mime/src/mimeJSComponents.js
@@ -382,17 +382,24 @@ MimeAddressParser.prototype = {
       return this.makeMailboxObject('', aDisplayName);
     }
   },
 
   // What follows is the deprecated API that will be removed shortly.
 
   parseHeadersWithArray: function (aHeader, aAddrs, aNames, aFullNames) {
     let addrs = [], names = [], fullNames = [];
-    let allAddresses = this.parseEncodedHeader(aHeader, undefined, false);
+    // Parse header, but without HEADER_OPTION_ALLOW_RAW.
+    let value = MimeParser.parseHeaderField(aHeader || "",
+                                            MimeParser.HEADER_ADDRESS |
+                                            MimeParser.HEADER_OPTION_DECODE_2231 |
+                                            MimeParser.HEADER_OPTION_DECODE_2047,
+                                            undefined);
+    let allAddresses = fixArray(value, false);
+
     // Don't index the dummy empty address.
     if (aHeader.trim() == "")
       allAddresses = [];
     for (let address of allAddresses) {
       addrs.push(address.email);
       names.push(address.name || null);
       fullNames.push(address.toString());
     }