Bug 1088975 - Answering mail with sendername containing encoded special chars and comma creates two To-entries, r=Fallen, a=rkent THUNDERBIRD_38_VERBRANCH
authorR Kent James <rkent@caspia.com>
Tue, 19 May 2015 11:26:23 -0700
branchTHUNDERBIRD_38_VERBRANCH
changeset 26048 bdb4cfe7cf58ae58a13af7f1d47b07b1872f2f20
parent 26046 433866b2dc107435c9772cc11d7d26ef9fd97caf
child 26049 cfca7dcba68a7457e5e8f86b91d7f2a5d645cf8a
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen, rkent
bugs1088975
Bug 1088975 - Answering mail with sendername containing encoded special chars and comma creates two To-entries, r=Fallen, a=rkent * * *
mailnews/compose/test/unit/test_attachment.js
mailnews/mime/jsmime/jsmime.js
mailnews/mime/jsmime/test/test_header_emitter.js
--- a/mailnews/compose/test/unit/test_attachment.js
+++ b/mailnews/compose/test/unit/test_attachment.js
@@ -41,27 +41,27 @@ const expectedCD1 = "Content-Disposition
 const ParamFoldingPref = {
   RFC2047: 0,
   RFC2047WithCRLF: 1,
   RFC2231: 2
 }
 
 const expectedCTList0 = {
   RFC2047: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
-           ' name="=?UTF-8?Q?_!=22#$%&\'=28=29*+,-./0123456789:;<=3d>=3f@ABCDEFGHIJKLMNO?='+
-           '=?UTF-8?Q?PQRSTUVWXYZ[\\\\]^=5f`abcdefghijklmnopqrstuvwxyz{|}~=c2=a0?='+
+           ' name="=?UTF-8?Q?_!=22#$%&\'=28=29*+=2c-./0123456789:;<=3d>=3f@ABCDEFGHIJKLM?='+
+           '=?UTF-8?Q?NOPQRSTUVWXYZ[\\\\]^=5f`abcdefghijklmnopqrstuvwxyz{|}~=c2=a0?='+
            '=?UTF-8?B?wqHCosKjwqTCpcKmwqfCqMKpwqrCq8Kswq3CrsKvwrDCscKywrPCtMK1?='+
            '=?UTF-8?B?wrbCt8K4wrnCusK7wrzCvcK+wr/DgMOBw4LDg8OEw4XDhsOHw4jDicOK?='+
            '=?UTF-8?B?w4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOf?='+
            '=?UTF-8?B?w6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0?='+
            '=?UTF-8?B?w7XDtsO3w7jDucO6w7vDvMO9w77Dvy50eHQ=?="\r\n',
 
   RFC2047WithCRLF: 'Content-Type: text/plain; charset=US-ASCII;\r\n'+
-                   ' name="=?UTF-8?Q?_!=22#$%&\'=28=29*+,-./0123456789:;<=3d>=3f@ABCDEFGHIJKLMNO?=\r\n'+
-                   ' =?UTF-8?Q?PQRSTUVWXYZ[\\\\]^=5f`abcdefghijklmnopqrstuvwxyz{|}~=c2=a0?=\r\n'+
+                   ' name="=?UTF-8?Q?_!=22#$%&\'=28=29*+=2c-./0123456789:;<=3d>=3f@ABCDEFGHIJKLM?=\r\n'+
+                   ' =?UTF-8?Q?NOPQRSTUVWXYZ[\\\\]^=5f`abcdefghijklmnopqrstuvwxyz{|}~=c2=a0?=\r\n'+
                    ' =?UTF-8?B?wqHCosKjwqTCpcKmwqfCqMKpwqrCq8Kswq3CrsKvwrDCscKywrPCtMK1?=\r\n'+
                    ' =?UTF-8?B?wrbCt8K4wrnCusK7wrzCvcK+wr/DgMOBw4LDg8OEw4XDhsOHw4jDicOK?=\r\n'+
                    ' =?UTF-8?B?w4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOf?=\r\n'+
                    ' =?UTF-8?B?w6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0?=\r\n'+
                    ' =?UTF-8?B?w7XDtsO3w7jDucO6w7vDvMO9w77Dvy50eHQ=?="\r\n',
 
   RFC2231: 'Content-Type: text/plain; charset=US-ASCII\r\n'
 }
--- a/mailnews/mime/jsmime/jsmime.js
+++ b/mailnews/mime/jsmime/jsmime.js
@@ -2842,17 +2842,17 @@ HeaderEmitter.prototype.addPhrase = func
 
 /// A regular expression for characters that need to be encoded.
 let nonAsciiRe = /[^\x20-\x7e]/;
 
 /// The beginnings of RFC 2047 encoded-word
 const b64Prelude = "=?UTF-8?B?", qpPrelude = "=?UTF-8?Q?";
 
 /// A list of ASCII characters forbidden in RFC 2047 encoded-words
-const qpForbidden = "=?_()\"";
+const qpForbidden = "=?_()\",";
 
 const hexString = "0123456789abcdef";
 
 /**
  * Add a block of text as a single RFC 2047 encoded word. This does not try to
  * split words if they are too long.
  *
  * @private
--- a/mailnews/mime/jsmime/test/test_header_emitter.js
+++ b/mailnews/mime/jsmime/test/test_header_emitter.js
@@ -92,16 +92,21 @@ suite('headeremitter', function () {
         "=?UTF-8?Q?dioxyg=c3=a8ne?=\r\n <a@a.c>"],
       // Prefer QP if base64 and QP are exactly the same length
       [[{name: "oxyg\u00e8ne", email: "a@a.c"}],
       // =?UTF-8?B?b3h5Z8OobmU=?=
         "=?UTF-8?Q?oxyg=c3=a8ne?=\r\n <a@a.c>"],
       [[{name: "\ud83d\udca9\ud83d\udca9\ud83d\udca9\ud83d\udca9",
         email: "a@a.c"}],
         "=?UTF-8?B?8J+SqfCfkqnwn5Kp?=\r\n =?UTF-8?B?8J+SqQ==?= <a@a.c>"],
+      // Bug 1088975: Since the encoded-word should be recognized as an atom,
+      // encode commas.
+      [[{name: "B\u00fcg 1088975, FirstName", email: "a@b.c"}],
+        "=?UTF-8?Q?B=c3=bcg_1088975?=\r\n" +
+        " =?UTF-8?Q?=2c_FirstName?=\r\n <a@b.c>"],
     ];
     header_tests.forEach(function (data) {
       arrayTest(data, function () {
         let emitter = headeremitter.makeStreamingEmitter(handler, {
           softMargin: 30,
           useASCII: true
         });
         handler.reset(data[1]);
@@ -122,22 +127,22 @@ suite('headeremitter', function () {
         for (let line of this.output.split('\r\n'))
           assert.ok(line.length <= 30, "Line is too long");
       }
     }
     let header_tests = [
       ["My house   burned down!", "My house burned down!"],
 
       // Which variables need to be encoded in QP encoding?
-      ["! \" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~ \x7f",
-        "=?UTF-8?Q?!_=22_#_$_%_&_'_?=\r\n" +
-        " =?UTF-8?Q?=28_=29_*_+_,_-_.?=\r\n" +
-        " =?UTF-8?Q?_/_:_;_<_=3d_>_?=\r\n" +
-        " =?UTF-8?Q?=3f_@_[_\\_]_^_=5f?=\r\n" +
-        " =?UTF-8?Q?_`_{_|_}_~_=7f?="],
+      ["! \" # $ % & ' ( ) * + - .", 
+       "! \" # $ % & ' ( ) * + - ."],
+      [" / : ; < = > ? , @ [ \\ ] ^ _ ` { | } ~ \x7f",
+        "=?UTF-8?Q?_/_:_;_<_=3d_>_=3f?=\r\n" +
+        " =?UTF-8?Q?_=2c_@_[_\\_]_^_?=\r\n" +
+        " =?UTF-8?Q?=5f_`_{_|_}_~_=7f?="],
       // But non-printable characters don't need it in the first place!
       ["! \" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~",
         "! \" # $ % & ' ( ) * + , - . /\r\n" +
         " : ; < = > ? @ [ \\ ] ^ _ ` { |\r\n" +
         " } ~"],
 
       // Test to make sure 2047-encoding chooses the right values.
       ["\u001f", "=?UTF-8?Q?=1f?="],