From 9dc8ba5cad18e38be4cb525defed7c4a9c161121 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Thu, 20 Jan 2011 13:30:16 -0800 Subject: [PATCH] Strip content of the "head" tag Bug: 3285281 Change-Id: I1183697ad09fbf8740e3529fecfa59cf6650b2f9 --- src/com/android/email/Snippet.java | 7 +++++-- tests/src/com/android/email/SnippetTests.java | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/Snippet.java b/src/com/android/email/Snippet.java index cb25f47aa..6d52b347f 100644 --- a/src/com/android/email/Snippet.java +++ b/src/com/android/email/Snippet.java @@ -42,7 +42,9 @@ public class Snippet { /*package*/ static final char NON_BREAKING_SPACE_CHARACTER = (char)160; // Tags whose content must be stripped as well - static final String[] STRIP_TAGS = new String[] {"title ", "script", "style ", "applet"}; + static final String[] STRIP_TAGS = + new String[] {"title", "script", "style", "applet", "head"}; + // The number of characters we peel off for testing against STRIP_TAGS static final int STRIP_TAG_LENGTH = 6; static final Map ESCAPE_STRINGS; @@ -373,8 +375,9 @@ public class Snippet { String tagLowerCase = tag.toLowerCase(); boolean stripContent = false; for (String stripTag: STRIP_TAGS) { - if (stripTag.equals(tagLowerCase)) { + if (tagLowerCase.startsWith(stripTag)) { stripContent = true; + tag = tag.substring(0, stripTag.length()); break; } } diff --git a/tests/src/com/android/email/SnippetTests.java b/tests/src/com/android/email/SnippetTests.java index 3d3a018f6..60625e57d 100644 --- a/tests/src/com/android/email/SnippetTests.java +++ b/tests/src/com/android/email/SnippetTests.java @@ -128,6 +128,8 @@ public class SnippetTests extends AndroidTestCase { "VisibleAgainVisible")); assertEquals("VisibleAgainVisible", Snippet.fromHtmlText( "Visible