File tree Expand file tree Collapse file tree
main/java/org/archive/resource/html
test/java/org/archive/resource/html Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public class ExtractingParseObserver implements ParseObserver {
2929 boolean inPre = false ;
3030
3131 protected static String cssUrlPatString =
32- "url\\ s*\\ (\\ s*((?: \\ \\ ?[ \" '])?.+?(?: \\ \\ ?[ \" ']) ?)\\ s*\\ )" ;
32+ "url\\ s*\\ (\\ s*([^) \\ s]{1,8000} ?)\\ s*\\ )" ;
3333 protected static String cssUrlTrimPatString =
3434 "^(?:\\ \\ ?[\" '])+|(?:\\ \\ ?[\" '])+$" ;
3535 protected static String cssImportNoUrlPatString =
Original file line number Diff line number Diff line change @@ -93,6 +93,24 @@ public void testHandleStyleNodeNoHangupTruncated() throws Exception {
9393 checkExtract (test );
9494 }
9595
96+ /**
97+ * Test whether the pattern matcher does not stack overflow with overlong
98+ * sequence of quote characters around a CSS link.
99+ */
100+ public void testHandleStyleNodeNoStackOverflow () throws Exception {
101+ StringBuilder sb = new StringBuilder ();
102+ sb .append ("url(" );
103+ for (int i = 0 ; i < 20000 ; i ++)
104+ sb .append ('\'' );
105+ sb .append ("foos.gif" );
106+ for (int i = 0 ; i < 20000 ; i ++)
107+ sb .append ('\'' );
108+ sb .append (");" );
109+ String [] test = new String [1 ];
110+ test [0 ] = sb .toString ();
111+ checkExtract (test );
112+ }
113+
96114 private void checkExtract (String [] data ) throws JSONException {
97115// System.err.format("CSS(%s) want[0](%s)\n",css,want[0]);
98116 String css = data [0 ];
You can’t perform that action at this time.
0 commit comments