Bug 759422 - Remove e4x from selectionsummaries, r=mkmelin.
authorJoshua Cranmer <Pidgeot18@gmail.com>
Sat, 02 Feb 2013 12:59:48 -0600
changeset 14778 eb1a4a4c5a76c040279c84fe6c1950c5d76c9585
parent 14777 17fd50faed6c822a0a3df644d9fe11d1ab0d11f5
child 14779 078dd301fa0c065beab7898a99fc60205b3b14f1
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs759422
Bug 759422 - Remove e4x from selectionsummaries, r=mkmelin.
mail/base/content/selectionsummaries.js
--- a/mail/base/content/selectionsummaries.js
+++ b/mail/base/content/selectionsummaries.js
@@ -104,16 +104,22 @@ function _mm_FormatDisplayName(aHeaderPa
       names.value[0] || addresses.value[0];
   }
   else {
     // Something strange happened, just return the raw header value.
     return aHeaderValue;
   }
 }
 
+function _mm_escapeHTML(aUnescaped) {
+  return aUnescaped.replace('&', "&amp;", 'g')
+                   .replace('<', "&lt;", 'g')
+                   .replace('>', "&gt;", 'g');
+}
+
 /**
  * the MultiMessageSummary class is responsible for populating the message pane
  * with a reasonable summary of a set of messages that span more than one
  * thread.
  *
  * It uses the same multimessage iframe as ThreadSummary, so both it
  * and ThreadSummary should be careful to clean up the other's work
  * before inserting their DOM nodes into the frame.
@@ -282,33 +288,35 @@ MultiMessageSummary.prototype = {
       if (numMsgs > 1) {
         countstring += "(";
         countstring += PluralForm.get(numMsgs, gSelectionSummaryStrings["numMsgs"]).replace('#1', numMsgs);
         if (countUnread)
           countstring += PluralForm.get(countUnread, gSelectionSummaryStrings["countUnread"]).replace('#1', countUnread);
         countstring += ")";
       }
 
-      let msgContents = <div class="row">
-                          <div class="star"/>
-                          <div class="header">
-                            <div class="wrappedsubject">
-                              <div class="author">{author}</div>
-                              <div class="subject link">{subject}</div>
-                              <div class="count">{countstring}</div>
-                              <div class="tags"></div>
-                            </div>
-                            <div class="snippet"></div>
-                          </div>
-                        </div>;
+      let msgContents = '<div class="row">' +
+                        '  <div class="star"/>' +
+                        '  <div class="header">' +
+                        '    <div class="wrappedsubject">' +
+                        '      <div class="author">' +
+                                  _mm_escapeHTML(author) + '</div>' +
+                        '      <div class="subject link">' +
+                                  _mm_escapeHTML(subject) + '</div>' +
+                        '      <div class="count">' + countstring + '</div>' +
+                        '      <div class="tags"></div>' +
+                        '    </div>' +
+                        '    <div class="snippet"></div>' +
+                        '  </div>' +
+                        '</div>';
 
       let msgNode = htmlpane.contentDocument.createElement("div");
       // innerHTML is safe here because all of the data in msgContents is
       // either generated from integers or escaped to be safe.
-      msgNode.innerHTML = msgContents.toXMLString();
+      msgNode.innerHTML = msgContents;
       _mm_addClass(msgNode, msg_classes);
       messagesElt.appendChild(msgNode);
 
       let snippetNode = msgNode.getElementsByClassName("snippet")[0];
       let authorNode = msgNode.getElementsByClassName("author")[0];
       try {
         MsgHdrToMimeMessage(msgs[0], null, function(aMsgHdr, aMimeMsg) {
           if (aMimeMsg == null) /* shouldn't happen, but sometimes does? */
@@ -553,32 +561,33 @@ ThreadSummary.prototype = {
       if (! msgHdr.isRead)
         msg_classes += " unread";
       if (msgHdr.isFlagged)
         msg_classes += " starred";
 
       let senderName = _mm_FormatDisplayName(headerParser, msgHdr.mime2DecodedAuthor, "from");
       let date = makeFriendlyDateAgo(new Date(msgHdr.date/1000));
 
-      let msgContents = <div class="row">
-                          <div class="star"/>
-                          <div class="header">
-                            <div class="wrappedsender">
-                              <div class="sender link">{senderName}</div>
-                              <div class="date">{date}</div>
-                              <div class="tags"></div>
-                            </div>
-                            <div class="snippet"></div>
-                          </div>
-                        </div>;
+      let msgContents = '<div class="row">' +
+                        '  <div class="star"/>' +
+                        '  <div class="header">' +
+                        '    <div class="wrappedsender">' +
+                        '      <div class="sender link">' +
+                                 _mm_escapeHTML(senderName) + '</div>' +
+                        '      <div class="date">' + date + '</div>' +
+                        '      <div class="tags"></div>' +
+                        '    </div>' +
+                        '    <div class="snippet"></div>' +
+                        '  </div>' +
+                        '</div>';
 
       let msgNode = htmlpane.contentDocument.createElement("div");
       // innerHTML is safe here because all of the data in msgContents is
       // either generated from integers or escaped to be safe.
-      msgNode.innerHTML = msgContents.toXMLString();
+      msgNode.innerHTML = msgContents;
       _mm_addClass(msgNode, msg_classes);
       messagesElt.appendChild(msgNode);
 
       let key = msgHdr.messageKey + msgHdr.folder.URI;
       let snippetNode = msgNode.getElementsByClassName("snippet")[0];
       let senderNode = msgNode.getElementsByClassName("sender")[0];
       try {
         MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {