Oscar Scholten pushed to branch master at cms-community / hippo-cms
Commits: b817831e by Oscar Scholten at 2016-10-17T10:04:09+02:00 CMS-10469 bumping HtmlCleaner to 2.16 and adding tests - adding tests for this issue and other issues that can now be closed: CMS-9563 and CMS-9570 - - - - - 2 changed files: - pom.xml - richtext/frontend/src/test/java/org/hippoecm/frontend/plugins/richtext/htmlcleaner/HtmlCleanerPluginTest.java Changes: ===================================== pom.xml ===================================== --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,7 @@ <hippo.ckeditor.version>4.5.11-h1-SNAPSHOT</hippo.ckeditor.version> <jslint.plugin.version>1.0.1</jslint.plugin.version> - <sf.htmlcleaner.version>2.12</sf.htmlcleaner.version> + <sf.htmlcleaner.version>2.16</sf.htmlcleaner.version> </properties> ===================================== richtext/frontend/src/test/java/org/hippoecm/frontend/plugins/richtext/htmlcleaner/HtmlCleanerPluginTest.java ===================================== --- a/richtext/frontend/src/test/java/org/hippoecm/frontend/plugins/richtext/htmlcleaner/HtmlCleanerPluginTest.java +++ b/richtext/frontend/src/test/java/org/hippoecm/frontend/plugins/richtext/htmlcleaner/HtmlCleanerPluginTest.java @@ -131,6 +131,58 @@ public class HtmlCleanerPluginTest extends PluginTest { } @Test + public void testQuoteConversion() throws Exception { + final IPluginConfig pluginConfig = getPluginConfig(); + final HtmlCleanerPlugin htmlCleanerPlugin = new HtmlCleanerPlugin(null, pluginConfig); + + final String html = htmlCleanerPlugin.clean("' \" ' "", false, null, null); + + assertEquals("' \" ' \"", html); + } + + @Test + public void expectScriptTagIsNotRemoved() throws Exception { + final IPluginConfig pluginConfig = getPluginConfig(); + final HtmlCleanerPlugin htmlCleanerPlugin = new HtmlCleanerPlugin(null, pluginConfig); + + final String original = "<h1><style type=\"text/css\" scoped>h1 {color:black;}</style>42</h1>"; + final String expected = "<h1><style type=\"text/css\" scoped=\"scoped\">h1 {color:black;}</style>42</h1>"; + final String html = htmlCleanerPlugin.clean(original, false, null, null); + + assertEquals(expected, html); + } + + @Test + public void expectLoopFinishes() throws Exception { + final IPluginConfig pluginConfig = getPluginConfig(); + final HtmlCleanerPlugin htmlCleanerPlugin = new HtmlCleanerPlugin(null, pluginConfig); + + final String original = "<div>\n" + + " <picture>\n" + + "<source media=\"(max-width: 700px)\" sizes=\"(max-width: 500px) 50vw, 10vw\"\n" + + "srcset=\"stick-figure-narrow.png 138w, stick-figure-hd-narrow.png 138w\">\n" + + "\n" + + "<source media=\"(max-width: 1400px)\" sizes=\"(max-width: 1000px) 100vw, 50vw\"\n" + + "srcset=\"stick-figure.png 416w, stick-figure-hd.png 416w\">\n" + + "\n" + + "<img src=\"stick-original.png\" alt=\"Human\">\n" + + "</picture>\n" + + "</div>"; + final String expected = "<div>\n" + + " <picture>\n" + + "<audio><source media=\"(max-width: 700px)\" sizes=\"(max-width: 500px) 50vw, 10vw\" srcset=\"stick-figure-narrow.png 138w, stick-figure-hd-narrow.png 138w\" />\n" + + "\n" + + "<source media=\"(max-width: 1400px)\" sizes=\"(max-width: 1000px) 100vw, 50vw\" srcset=\"stick-figure.png 416w, stick-figure-hd.png 416w\" />\n" + + "\n" + + "<img src=\"stick-original.png\" alt=\"Human\" />\n" + + "</audio></picture></div>"; + + final String html = htmlCleanerPlugin.clean(original, false, null, null); + + assertEquals(expected, html); + } + + @Test public void serviceIdIsConfigurable() { final IPluginContext context = EasyMock.createMock(IPluginContext.class); context.registerService(isA(HtmlCleanerPlugin.class), eq("myHtmlCleaner")); View it on GitLab: https://code.onehippo.org/cms-community/hippo-cms/commit/b817831ec511912eddfcc96466ce78f5d1bf6993
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn