Skip to content

Commit

Permalink
test removing unescaping in XmlWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
davidh44 committed Dec 15, 2023
1 parent d43c125 commit 6b9beb3
Showing 1 changed file with 0 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ final class XmlWriter {
/** Standard XML prolog to add to the beginning of each XML document. */
private static final String PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

private static final String[] UNESCAPE_SEARCHES = {
// Ampersands should always be the last to unescape
"&quot;", "&apos;", "&lt;", "&gt;", "&#x0D;", "&#x0A;", "&amp;"
};

private static final String[] UNESCAPE_REPLACEMENTS = {
"\"", "'", "<", ">", "\r", "\n", "&"
};

private static final String[] ESCAPE_SEARCHES = {
// Ampersands should always be the first to escape
"&", "\"", "'", "<", ">", "\r", "\n"
Expand Down Expand Up @@ -206,10 +197,6 @@ private void append(String s) {
}

private String escapeXmlEntities(String s) {
// Unescape any escaped characters.
if (s.contains("&")) {
s = StringUtils.replaceEach(s, UNESCAPE_SEARCHES, UNESCAPE_REPLACEMENTS);
}
return StringUtils.replaceEach(s, ESCAPE_SEARCHES, ESCAPE_REPLACEMENTS);
}
}

0 comments on commit 6b9beb3

Please sign in to comment.