Bug 1175839 - Make [] special characters in encoding. r=rkent a=rkent
authorJorg K
Sun, 13 Dec 2015 14:57:00 +0100
changeset 22258 72d1dfcc6d465fdd197874667cf2cc5ed289ed91
parent 22257 3911bc2095254f8d37a08c6a83305347293ec6b5
child 22259 66db30aed2d9c9c21a06ba0bdc0a09d18575adf3
push id101
push userkent@caspia.com
push dateFri, 29 Apr 2016 20:46:04 +0000
treeherdercomm-esr38@66db30aed2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs1175839
Bug 1175839 - Make [] special characters in encoding. r=rkent a=rkent
mailnews/mime/jsmime/jsmime.js
mailnews/mime/jsmime/test/test_header.js
mailnews/mime/jsmime/test/test_header_emitter.js
--- a/mailnews/mime/jsmime/jsmime.js
+++ b/mailnews/mime/jsmime/jsmime.js
@@ -253,17 +253,17 @@ addHeader("Resent-Message-ID", parseMess
 // RFC 2047
 structuredDecoders.set("Content-Transfer-Encoding", function (values) {
   return values[0].toLowerCase();
 });
 structuredEncoders.set("Content-Transfer-Encoding", writeUnstructured);
 
 // Some clients like outlook.com send non-compliant References headers that
 // separate values using commas. Also, some clients don't separate References
-// with spaces, since these are optional accordint to RFC2822. So here we
+// with spaces, since these are optional according to RFC2822. So here we
 // preprocess these headers (see bug 1154521 and bug 1197686).
 function preprocessMessageIDs(values) {
   let msgId = /<[^>]*>/g;
   let match, ids = [];
   while ((match = msgId.exec(values)) !== null) {
     ids.push(match[0]);
   }
   return ids.join(' ');
@@ -3016,17 +3016,17 @@ HeaderEmitter.prototype.addStructuredHea
  * @param {String} addr.email The email of the address to add.
  * @see headerparser.parseAddressingHeader
  */
 HeaderEmitter.prototype.addAddress = function (addr) {
   // If we have a display name, add that first.
   if (addr.name) {
     // This is a simple estimate that keeps names on one line if possible.
     this._reserveTokenSpace(addr.name.length + addr.email.length + 3);
-    this.addPhrase(addr.name, ",()<>:;.\"", true);
+    this.addPhrase(addr.name, ",()<>[]:;.\"", true);
 
     // If we don't have an email address, don't write out the angle brackets for
     // the address. It's already an abnormal situation should this appear, and
     // this has better round-tripping properties.
     if (!addr.email)
       return;
 
     this.addText("<", false);
@@ -3071,17 +3071,17 @@ HeaderEmitter.prototype.addAddresses = f
       this.addText(", ", true);
     needsComma = true;
 
     if ("email" in addr) {
       this.addAddress(addr);
     } else {
       // A group has format name: member, member;
       // Note that we still add a comma after the group is completed.
-      this.addPhrase(addr.name, ",()<>:;.\"", false);
+      this.addPhrase(addr.name, ",()<>[]:;.\"", false);
       this.addText(":", true);
 
       this.addAddresses(addr.group);
       this.addText(";", true);
     }
   }
 };
 
--- a/mailnews/mime/jsmime/test/test_header.js
+++ b/mailnews/mime/jsmime/test/test_header.js
@@ -380,37 +380,37 @@ suite('headerparser', function () {
       ["(=?ISO-8859-1?Q?Joe_L=F6we?=) jl3@b.c (c2)", [{name: "c2", email: "jl3@b.c"}]],
       ["=?ISO-8859-1?Q?Joe_L=F6we?= <jl3@b.c> (c2)", [{name: "Joe Löwe (c2)", email: "jl3@b.c"}]],
       ["(=?ISO-8859-1?Q?Joe_L=F6we?=) <jl3@b.c> (c2)", [{name: "(Joe Löwe) (c2)", email: "jl3@b.c"}]],
       // Bug 1141446: Malformed From addresses with erroneous quotes,
       // note: acute accents: a \u00E1, e \u00E9, i \u00ED, o \u00F3, u \u00FA.
       ["\"=?UTF-8?Q?Jazzy_Fern=C3=A1ndez_Nunoz?= jazzy.f.nunoz@example.com " +
         "[BCN-FC]\" <Barcelona-Freecycle-noreply@yahoogroups.com>",
         [{name: "Jazzy Fern\u00E1ndez Nunoz jazzy.f.nunoz@example.com [BCN-FC]",
-      email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
+          email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
       ["\"=?UTF-8?B?TWlyaWFtIEJlcm5hYsOpIFBlcmVsbMOz?= miriam@example.com "+
         "[BCN-FC]\" <Barcelona-Freecycle-noreply@yahoogroups.com>",
         [{name: "Miriam Bernab\u00E9 Perell\u00F3 miriam@example.com [BCN-FC]",
-      email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
+          email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
       ["\"=?iso-8859-1?Q?First_Mar=EDa_Furi=F3_Gancho?= mail@yahoo.es "+
         "[BCN-FC]\" <Barcelona-Freecycle-noreply@yahoogroups.com>",
         [{name: "First Mar\u00EDa Furi\u00F3 Gancho mail@yahoo.es [BCN-FC]",
-      email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
+          email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
       ["\"=?iso-8859-1?B?U29maWEgQ2FzdGVsbPMgUm9tZXJv?= sonia@example.com "+
         "[BCN-FC]\" <Barcelona-Freecycle-noreply@yahoogroups.com>",
         [{name: "Sofia Castell\u00F3 Romero sonia@example.com [BCN-FC]",
-      email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
+          email: "Barcelona-Freecycle-noreply@yahoogroups.com"}]],
       ["=?iso-8859-1?Q?Klaus_Eisschl=E4ger_=28k=2Eeisschlaeger=40t-onli?=" +
         "=?iso-8859-1?Q?ne=2Ede=29?= <k.eisschlaeger@t-online.de>",
-      [{name: "Klaus Eisschläger (k.eisschlaeger@t-online.de)",
-        email: "k.eisschlaeger@t-online.de"}]],
+        [{name: "Klaus Eisschläger (k.eisschlaeger@t-online.de)",
+          email: "k.eisschlaeger@t-online.de"}]],
       ["\"=?UTF-8?Q?=22Claudia_R=C3=B6hschicht=22?= Claudia_Roehschicht@web.de [freecycle-berlin]\" " +
         "<freecycle-berlin-noreply@yahoogroups.de>",
-      [{name: "\"Claudia Röhschicht\" Claudia_Roehschicht@web.de [freecycle-berlin]",
-        email: "freecycle-berlin-noreply@yahoogroups.de"}]],
+        [{name: "\"Claudia Röhschicht\" Claudia_Roehschicht@web.de [freecycle-berlin]",
+          email: "freecycle-berlin-noreply@yahoogroups.de"}]],
     ];
     header_tests.forEach(function (data) {
       arrayTest(data, function () {
         assert.deepEqual(headerparser.parseAddressingHeader(data[0], true),
           data[1]);
       });
     });
   });
--- a/mailnews/mime/jsmime/test/test_header_emitter.js
+++ b/mailnews/mime/jsmime/test/test_header_emitter.js
@@ -55,16 +55,21 @@ suite('headeremitter', function () {
       [[{name: "Doe, John", email: "a@a.com"}], "\"Doe, John\" <a@a.com>"],
       // This one violates the line length, so it underquotes instead.
       [[{name: "A really, really long name to quote", email: "a@example.com"}],
         "A \"really,\" really long name\r\n to quote <a@example.com>"],
       [[{name: "Group", group: [{name: "", email: "a@a.c"},
                                 {name: "", email: "b@b.c"}]}],
         "Group: a@a.c, b@b.c;"],
       [[{name: "No email address", email: ""}], "No email address"],
+      [[{name: "]user[ domain", email: "user@d.com"}],
+        "\"]user[ domain\" <user@d.com>"],
+      [[{name: "Group", group: [{name: "]u[ d", email: "a@a.c"},
+                                {name: "]u[ c", email: "b@b.c"}]}],
+        "Group: \"]u[ d\" <a@a.c>,\r\n \"]u[ c\" <b@b.c>;"],
     ];
     header_tests.forEach(function (data) {
       arrayTest(data, function () {
         let emitter = headeremitter.makeStreamingEmitter(handler, {
           softMargin: 30,
           useASCII: false,
         });
         handler.reset(data[1]);