Bug 1384361 - HTML message with align attributes must not be convertible to plaintext. r=aceman
authorThomas Duellmann <bugzilla2007@duellmann24.net>
Wed, 26 Jul 2017 02:38:14 +0200
changeset 28507 8bbe89ca7478fb2ce0a8afc5c65a39fe77a5f51d
parent 28506 1f0a3e17464ffabc53248e3a027fd705a9275be6
child 28508 942c522bd77ecffa2c9aa085d185b7b0ece0e645
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1384361
Bug 1384361 - HTML message with align attributes must not be convertible to plaintext. r=aceman
mailnews/compose/src/nsMsgCompose.cpp
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -5407,17 +5407,18 @@ nsresult nsMsgCompose::TagConvertible(ns
 
     nsAutoString element;
     rv = node->GetNodeName(element);
     if (NS_FAILED(rv))
       return rv;
 
     nsCOMPtr<nsIDOMNode> pItem;
 
-    // style attribute on any element can change layout in any way, so that is not convertible.
+    // A style attribute on any element can change layout in any way,
+    // so that is not convertible.
     nsAutoString attribValue;
     if (NS_SUCCEEDED(node->GetAttribute(NS_LITERAL_STRING("style"), attribValue)) &&
         !attribValue.IsEmpty())
     {
       *_retval = nsIMsgCompConvertible::No;
       return NS_OK;
     }
 
@@ -5427,24 +5428,34 @@ nsresult nsMsgCompose::TagConvertible(ns
     // other context (e.g. in microformats).
     if (NS_SUCCEEDED(node->GetAttribute(NS_LITERAL_STRING("class"), attribValue)) &&
         !attribValue.IsEmpty() &&
         !StringBeginsWith(attribValue, NS_LITERAL_STRING("moz-"), nsCaseInsensitiveStringComparator()))
     {
       *_retval = nsIMsgCompConvertible::No;
       return NS_OK;
     }
+
     // ID attributes can contain attached style/context or be target of links
     // so we should preserve them.
     if (NS_SUCCEEDED(node->GetAttribute(NS_LITERAL_STRING("id"), attribValue)) &&
         !attribValue.IsEmpty())
     {
       *_retval = nsIMsgCompConvertible::No;
       return NS_OK;
     }
+
+    // Alignment is not convertible; editor currently uses this.
+    if (NS_SUCCEEDED(node->GetAttribute(NS_LITERAL_STRING("align"), attribValue)) &&
+        !attribValue.IsEmpty())
+    {
+      *_retval = nsIMsgCompConvertible::No;
+      return NS_OK;
+    }
+
     if      ( // some "simple" elements without "style" attribute
               element.LowerCaseEqualsLiteral("br") ||
               element.LowerCaseEqualsLiteral("p") ||
               element.LowerCaseEqualsLiteral("pre") ||
               element.LowerCaseEqualsLiteral("tt") ||
               element.LowerCaseEqualsLiteral("html") ||
               element.LowerCaseEqualsLiteral("head") ||
               element.LowerCaseEqualsLiteral("meta") ||