Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paragraph regex #408

Merged
merged 2 commits into from
Dec 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/main/resources/antisamy-anythinggoes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<regexp name="anything" value=".*" />
<regexp name="numberOrPercent" value="(\d)+(%{0,1})" />
<regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)]|&amp;[0-9]{2};)*" />
<regexp name="paragraph" value="[\p{L}\p{N},'.\s\-_\(\)&amp;;]*" />
<regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+" />
<regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&amp;]*" /> <!-- force non-empty with a '+' at the end instead of '*' -->
<regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+" />
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 @@ -31,7 +31,7 @@

<regexp name="anything" value=".*" />
<regexp name="numberOrPercent" value="(\d)+(%{0,1})" />
<regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)]|&amp;[0-9]{2};)*" />
<regexp name="paragraph" value="[\p{L}\p{N},'.\s\-_\(\)&amp;;]*" />
<regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+" />
<regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&amp;]*" /> <!-- force non-empty with a '+' at the end instead of '*' -->
<regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+" />
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 @@ -33,7 +33,7 @@

<regexp name="anything" value=".*" />
<regexp name="numberOrPercent" value="(\d)+(%{0,1})" />
<regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)]|&amp;[0-9]{2};)*" />
<regexp name="paragraph" value="[\p{L}\p{N},'.\s\-_\(\)&amp;;]*" />
<regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+" />
<regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&amp;]*" /> <!-- force non-empty with a '+' at the end instead of '*' -->
<regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+" />
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 @@ -36,7 +36,7 @@

<regexp name="anything" value=".*" />
<regexp name="numberOrPercent" value="(\d)+(%{0,1})" />
<regexp name="paragraph" value="([\p{L}\p{N},'\.\s\-_\(\)]|&amp;[0-9]{2};)*" />
<regexp name="paragraph" value="[\p{L}\p{N},'.\s\-_\(\)&amp;;]*" />
<regexp name="htmlId" value="[a-zA-Z0-9\:\-_\.]+" />
<regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&amp;]*" /> <!-- force non-empty with a '+' at the end instead of '*' -->
<regexp name="htmlClass" value="[a-zA-Z0-9\s,\-_]+" />
Expand Down
16 changes: 16 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 @@ -2621,4 +2621,20 @@ public void testRawTextProcessingWhenPreservingComments() throws ScanException,
as.scan(payload, revised, AntiSamy.SAX).getCleanHTML(), not(containsString("mxss")));
}
}

@Test
public void testRegexStackOverflow() throws ScanException, PolicyException {
try {
String input =
"<img border=\"0\" width=\"320\" height=\"200\" style=\"width:3.368in;height:2.0486in\" id=\"id_123\" src=\"/url/uri\" alt=\"";
for (int i = 0; i < 2500; i++) {
input += "SampleText ";
}
input += "!\\\">";
as.scan(input, policy, AntiSamy.DOM).getCleanHTML();
as.scan(input, policy, AntiSamy.SAX).getCleanHTML();
} catch (StackOverflowError e) {
fail("Parser should not throw a stack overflow error");
}
}
}
Loading