Commit 7e9ed475 authored by Michael Hamann's avatar Michael Hamann
Browse files

XCOMMONS-901: Support both XHTML 1.0 and XHTML 5 in HtmlCleaner

* Fix case of HTML5 doctype, see https://github.com/whatwg/html/blob/main/FAQ.md#what-is-the-doctype-for-modern-html-documents
parent 329499db
......@@ -162,10 +162,11 @@ public Document clean(Reader originalHtmlContent, HTMLCleanerConfiguration confi
// result = new DomSerializer(cleanerProperties, false).createDOM(cleanedNode);
if (getHTMLVersion(configuration) == 5) {
cleanedNode.setDocType(new DoctypeToken("HTML", null, null, null));
cleanedNode.setDocType(new DoctypeToken(HTMLConstants.TAG_HTML, null, null, null));
} else {
cleanedNode.setDocType(new DoctypeToken("html", "PUBLIC", "-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
cleanedNode.setDocType(
new DoctypeToken(HTMLConstants.TAG_HTML, "PUBLIC", "-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
}
result =
new XWikiDOMSerializer(cleanerProperties).createDOM(getAvailableDocumentBuilder(), cleanedNode);
......
......@@ -35,7 +35,7 @@
public class HTML5HTMLCleanerTest extends DefaultHTMLCleanerTest
{
public static final String HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE HTML>\n";
+ "<!DOCTYPE html>\n";
private static final String HEADER_FULL = HEADER + "<html><head></head><body>";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment