From 4606bc7353c951dc71d6a4e757484e49677ad437 Mon Sep 17 00:00:00 2001 From: LiuXing-R Date: Wed, 15 Sep 2021 09:31:38 +0800 Subject: [PATCH] Support common CSS relative length units such as REM, VW, VH, etc --- src/main/resources/antisamy-anythinggoes.xml | 4 ++-- src/main/resources/antisamy-ebay.xml | 4 ++-- src/main/resources/antisamy-myspace.xml | 4 ++-- src/main/resources/antisamy.xml | 6 +++--- .../validator/html/test/AntiSamyTest.java | 21 +++++++++++++++++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/resources/antisamy-anythinggoes.xml b/src/main/resources/antisamy-anythinggoes.xml index 7ac09993..410d3020 100644 --- a/src/main/resources/antisamy-anythinggoes.xml +++ b/src/main/resources/antisamy-anythinggoes.xml @@ -102,8 +102,8 @@ http://www.w3.org/TR/html401/struct/global.html - - + + diff --git a/src/main/resources/antisamy-ebay.xml b/src/main/resources/antisamy-ebay.xml index 700ddb60..139497d7 100644 --- a/src/main/resources/antisamy-ebay.xml +++ b/src/main/resources/antisamy-ebay.xml @@ -100,8 +100,8 @@ http://www.w3.org/TR/html401/struct/global.html - - + + diff --git a/src/main/resources/antisamy-myspace.xml b/src/main/resources/antisamy-myspace.xml index 166165ce..0fd9e7d0 100644 --- a/src/main/resources/antisamy-myspace.xml +++ b/src/main/resources/antisamy-myspace.xml @@ -102,8 +102,8 @@ http://www.w3.org/TR/html401/struct/global.html - - + + diff --git a/src/main/resources/antisamy.xml b/src/main/resources/antisamy.xml index c6e2304f..2b84b7fb 100644 --- a/src/main/resources/antisamy.xml +++ b/src/main/resources/antisamy.xml @@ -106,9 +106,9 @@ http://www.w3.org/TR/html401/struct/global.html - - - + + + diff --git a/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java b/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java index 689402b0..ef7eb6d4 100644 --- a/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java +++ b/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java @@ -1527,5 +1527,26 @@ public void testGithubIssue101() throws ScanException, PolicyException { assertThat(as.scan("

Some text.

", policy, AntiSamy.DOM).getCleanHTML(), not(containsString("margin"))); assertThat(as.scan("

Some text.

", policy, AntiSamy.SAX).getCleanHTML(), not(containsString("margin"))); } + + @Test + public void testCSSUnits() throws ScanException, PolicyException { + String input = "
\n" + + "\t

Some text.

\n" + + "
"; + CleanResults cr = as.scan(input, policy, AntiSamy.DOM); + assertThat(cr.getCleanHTML(), containsString("ex")); + assertThat(cr.getCleanHTML(), containsString("px")); + assertThat(cr.getCleanHTML(), containsString("rem")); + assertThat(cr.getCleanHTML(), containsString("vw")); + assertThat(cr.getCleanHTML(), containsString("vh")); + assertThat(cr.getCleanHTML(), not(containsString("rpc"))); + cr = as.scan(input, policy, AntiSamy.SAX); + assertThat(cr.getCleanHTML(), containsString("ex")); + assertThat(cr.getCleanHTML(), containsString("px")); + assertThat(cr.getCleanHTML(), containsString("rem")); + assertThat(cr.getCleanHTML(), containsString("vw")); + assertThat(cr.getCleanHTML(), containsString("vh")); + assertThat(cr.getCleanHTML(), not(containsString("rpc"))); + } }