Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ protected org.apache.xml.serialize.HTMLSerializer getHTMLSerializer(
return new ASHTMLSerializer(w, format, policy);
}

/**
* Returns a new {@link HtmlSerializer} configured for the current policy. This is the preferred
* serializer that does not depend on the deprecated Xerces
* {@code org.apache.xml.serialize.HTMLSerializer}.
*
* @param w the writer to serialize into
* @return a fully configured {@link HtmlSerializer}
*/
protected HtmlSerializer getHtmlSerializer(Writer w) {
return new HtmlSerializer(w, policy);
}

protected String trim(String original, String cleaned) {
if (cleaned.endsWith("\n")) {
if (!original.endsWith("\n")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ public CleanResults scan(String html) throws ScanException {

StringWriter out = new StringWriter();

@SuppressWarnings("deprecation")
org.apache.xml.serialize.OutputFormat format = getOutputFormat();

//noinspection deprecation
org.apache.xml.serialize.HTMLSerializer serializer = getHTMLSerializer(out, format);
HtmlSerializer serializer = getHtmlSerializer(out);
serializer.serialize(dom);

/*
Expand Down
Loading