Skip to content

Commit

Permalink
Merge pull request #100 from LiuXing-R/change-lang-reg
Browse files Browse the repository at this point in the history
fix: change the regex of `lang` to support IANA subtags
  • Loading branch information
spassarop authored Aug 19, 2021
2 parents f109ea4 + f8d512a commit 2186c6a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-anythinggoes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ http://www.w3.org/TR/html401/struct/global.html

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
<regexp value="[a-zA-Z0-9-]{2,20}"/>
</regexp-list>
</attribute>
<attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-ebay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ http://www.w3.org/TR/html401/struct/global.html

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
<regexp value="[a-zA-Z0-9-]{2,20}"/>
</regexp-list>
</attribute>
<attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-myspace.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ http://www.w3.org/TR/html401/struct/global.html

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
<regexp value="[a-zA-Z0-9-]{2,20}"/>
</regexp-list>
</attribute>
<attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-slashdot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Slashdot allowed tags taken from "Reply" page:

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
<regexp value="[a-zA-Z0-9-]{2,20}"/>
</regexp-list>
</attribute>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-tinymce.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">

<regexp-list>
<regexp value="[a-zA-Z]{2,20}" />
<regexp value="[a-zA-Z0-9-]{2,20}" />
</regexp-list>
</attribute>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/antisamy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ http://www.w3.org/TR/html401/struct/global.html

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
<regexp value="[a-zA-Z0-9-]{2,20}"/>
</regexp-list>
</attribute>
<attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/owasp/validator/html/test/AntiSamyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1502,5 +1502,12 @@ public void entityReferenceEncodedInHtmlAttribute() throws ScanException, Policy
assertThat(as.scan("<p><a href=\"javascript&#00058x=1,%61%6c%65%72%74%28%22%62%6f%6f%6d%22%29\">xss</a></p>", revised, AntiSamy.SAX).getCleanHTML(),
containsString("javascript&amp;#00058"));
}

@Test
public void testGithubIssue99() throws ScanException, PolicyException {
// Test that the IANA subtags is not lost
assertThat(as.scan("<p lang=\"en-GB\">This paragraph is defined as British English.</p>", policy, AntiSamy.DOM).getCleanHTML(), containsString("lang=\"en-GB\""));
assertThat(as.scan("<p lang=\"en-GB\">This paragraph is defined as British English.</p>", policy, AntiSamy.SAX).getCleanHTML(), containsString("lang=\"en-GB\""));
}
}

0 comments on commit 2186c6a

Please sign in to comment.