Bug 669073 - Remove moz-txt-citetags from serialised HTML. r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Sat, 03 Sep 2016 21:57:21 +0200
changeset 27466 6e41f3a00c6b44924aacb1545844ea6cccf14669
parent 27465 459d9584f945dd404ca4819e3b87d41539f80bde
child 27467 ad5d914f09a9f3ea269445e5e80ef453fed1cbab
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)
reviewersmkmelin, jorgk
bugs669073
Bug 669073 - Remove moz-txt-citetags from serialised HTML. r=mkmelin a=jorgk
mailnews/compose/src/nsMsgComposeService.cpp
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -342,17 +342,32 @@ nsMsgComposeService::GetOrigWindowSelect
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = docEncoder->SetSelection(sel);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString selHTML;
   rv = docEncoder->EncodeToString(selHTML);
   NS_ENSURE_SUCCESS(rv, rv);
-  aSelHTML = NS_ConvertUTF16toUTF8(selHTML);
+
+  // Now remove <span class="moz-txt-citetags">&gt; </span>.
+  nsAutoCString html(NS_ConvertUTF16toUTF8(selHTML).get());
+  int32_t spanInd = html.Find("<span class=\"moz-txt-citetags\">");
+  while (spanInd != kNotFound) {
+    nsAutoCString right0(Substring(html, spanInd));
+    int32_t endInd = right0.Find("</span>");
+    if (endInd == kNotFound)
+      break;  // oops, where is the closing tag gone?
+    nsAutoCString right1(Substring(html, spanInd + endInd + 7));
+    html.SetLength(spanInd);
+    html.Append(right1);
+    spanInd = html.Find("<span class=\"moz-txt-citetags\">");
+  }
+
+  aSelHTML.Assign(html);
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, nsIMsgDBHdr *origMsgHdr, const char *originalMsgURI,
   MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * aIdentity, nsIMsgWindow *aMsgWindow)
 {