Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ExtractingParseObserver implements ParseObserver {
boolean inTitle = false;

protected static String cssUrlPatString =
"url\\s*\\(\\s*((?:\\\\?[\"'])?.+?(?:\\\\?[\"'])?)\\s*\\)";
"url\\s*\\(\\s*([^)\\s]{1,8000}?)\\s*\\)";
protected static String cssUrlTrimPatString =
"^(?:\\\\?[\"'])+|(?:\\\\?[\"'])+$";
protected static String cssImportNoUrlPatString =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ public void testHandleStyleNodeNoHangupTruncated() throws Exception {
checkExtract(test);
}

/**
* Test whether the pattern matcher does not stack overflow with overlong
* sequence of quote characters around a CSS link.
*/
public void testHandleStyleNodeNoStackOverflow() throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("url(");
for (int i = 0; i < 20000; i++)
sb.append('\'');
sb.append("foos.gif");
for (int i = 0; i < 20000; i++)
sb.append('\'');
sb.append(");");
String[] test = new String[1];
test[0] = sb.toString();
checkExtract(test);
}

private void checkExtract(String[] data) throws JSONException {
// System.err.format("CSS(%s) want[0](%s)\n",css,want[0]);
String css = data[0];
Expand Down