From d95e068a77ab47308229b1bad93b239d0ff2db04 Mon Sep 17 00:00:00 2001 From: Brian Murphy <brian.p.murphy@gmail.com> Date: Sun, 3 May 2015 21:35:35 -0400 Subject: [PATCH] [TEST] Add html found during testing to cause problems for the sanitizer. This change adds a html string that was found to cause problems for the sanitizer during testing. Original commit: elastic/x-pack-elasticsearch@275e7286742ebc15ee3975610b63bb37f795afbc --- .../watcher/actions/email/service/HtmlSanitizeTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/elasticsearch/watcher/actions/email/service/HtmlSanitizeTests.java b/src/test/java/org/elasticsearch/watcher/actions/email/service/HtmlSanitizeTests.java index 7d415a81525..dc831aa7019 100644 --- a/src/test/java/org/elasticsearch/watcher/actions/email/service/HtmlSanitizeTests.java +++ b/src/test/java/org/elasticsearch/watcher/actions/email/service/HtmlSanitizeTests.java @@ -66,5 +66,12 @@ public class HtmlSanitizeTests extends ElasticsearchTestCase { assertThat(sanitizedHtml, equalTo("This was a dangerous script")); } + @Test + public void test_HtmlSanitizer_FullHtmlWithMetaString() { + String needsSanitation = "<html><head></head><body><h1>Hello {{ctx.metadata.name}}</h1> meta <a href='https://www.google.com/search?q={{ctx.metadata.name}}'>Testlink</a>meta</body></html>"; + byte[] bytes = new byte[0]; + String sanitizedHtml = Profile.sanitizeHtml(ImmutableMap.of("foo", (Attachment) new Attachment.Bytes("foo", bytes, "")), needsSanitation); + assertThat(sanitizedHtml, equalTo("<head></head><body><h1>Hello {{ctx.metadata.name}}</h1> meta <a href=\"https://www.google.com/search?q={{ctx.metadata.name}}\" rel=\"nofollow\">Testlink</a>meta</body>")); + } }