Skip to content

Commit

Permalink
Fixed char encoding issue by using unicode escape. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
xeno6696 authored and nahsra committed Jul 27, 2017
1 parent be550ca commit 9129f27
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/test/java/org/owasp/validator/html/test/AntiSamyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -956,26 +956,26 @@ public void nestedCdataAttacks() throws ScanException, PolicyException {
public void issue101InternationalCharacterSupport() throws ScanException, PolicyException {
Policy revised = policy.cloneWithDirective(Policy.ENTITY_ENCODE_INTL_CHARS, "false");

String html = "<b>letter 'a' with umlaut: ä";
String html = "<b>letter 'a' with umlaut: \u00e4";
String crDom = as.scan(html, revised, AntiSamy.DOM).getCleanHTML();
String crSax = as.scan(html, revised, AntiSamy.SAX).getCleanHTML();
assertTrue(crDom.contains("ä"));
assertTrue(crSax.contains("ä"));
assertTrue(crDom.contains("\u00e4"));
assertTrue(crSax.contains("\u00e4"));

Policy revised2 = policy.cloneWithDirective(Policy.USE_XHTML, "false").cloneWithDirective(Policy.ENTITY_ENCODE_INTL_CHARS, "true");
crDom = as.scan(html, revised2, AntiSamy.DOM).getCleanHTML();
crSax = as.scan(html, revised2, AntiSamy.SAX).getCleanHTML();
assertTrue(!crDom.contains("ä"));
assertTrue(!crDom.contains("\u00e4"));
assertTrue(crDom.contains("&auml;"));
assertTrue(!crSax.contains("ä"));
assertTrue(!crSax.contains("\u00e4"));
assertTrue(crSax.contains("&auml;"));

Policy revised3 = policy.cloneWithDirective(Policy.USE_XHTML, "true").cloneWithDirective(Policy.ENTITY_ENCODE_INTL_CHARS, "true");
crDom = as.scan(html, revised3, AntiSamy.DOM).getCleanHTML();
crSax = as.scan(html, revised3, AntiSamy.SAX).getCleanHTML();
assertTrue(!crDom.contains("ä"));
assertTrue(!crDom.contains("\u00e4"));
assertTrue(crDom.contains("&auml;"));
assertTrue(!crSax.contains("ä"));
assertTrue(!crSax.contains("\u00e4"));
assertTrue(crSax.contains("&auml;"));
}

Expand Down

0 comments on commit 9129f27

Please sign in to comment.