From 5a666cec7b37948a1f77f5f88cb77d95e657a544 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Tue, 31 May 2011 13:42:37 -0700 Subject: [PATCH] Fix HTML escaping to not use ' ' is not a supported HTML entity in Exchange servers as well as the rendering engines MS use, so it doesn't get properly interpreted. This changes makes us use the safer XML/unicode equivalent of escape entities. Bug: 4495370 Change-Id: Id6cc544a4765e72d44cc874841e2f70d8e3af468 --- .../emailcommon/internet/Rfc822Output.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java index 36b72c5db..127eb8c6a 100644 --- a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java +++ b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java @@ -86,6 +86,20 @@ public class Rfc822Output { } } + /** + * Encodes a payload to be HTML safe with custom modifications. Specifically: + * + */ + private static String htmlEncodeForAlternate(String s) { + return TextUtils.htmlEncode(s) + .replaceAll("\\r?\\n", "
") + .replaceAll("'", "'"); + } + /** * Returns an HTML encoded message alternate */ @@ -94,11 +108,10 @@ public class Rfc822Output { return null; } StringBuffer altMessage = new StringBuffer(); - String htmlContent = TextUtils.htmlEncode(body.mTextContent); // Escape HTML reserved chars - altMessage.append(htmlContent.replaceAll("\\r?\\n", "
")); + altMessage.append(htmlEncodeForAlternate(body.mTextContent)); if (body.mIntroText != null) { String htmlIntro = TextUtils.htmlEncode(body.mIntroText); - altMessage.append(htmlIntro.replaceAll("\\r?\\n", "
")); + altMessage.append(htmlEncodeForAlternate(htmlIntro)); } if (!useSmartReply) { String htmlBody = getHtmlBody(body.mHtmlReply);