deayalas / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Fix CSS lexar's handling of empty url() #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The lexar is going into infinite regression on the input "url()", causing this 
issue: 
http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css.j
s?edit=1

Original issue reported on code.google.com by lannmar...@gmail.com on 6 Dec 2011 at 1:14

GoogleCodeExporter commented 9 years ago
Patch with regression test:

Index: tests/prettify_test.html
===================================================================
--- tests/prettify_test.html    (revision 194)
+++ tests/prettify_test.html    (working copy)
@@ -1087,6 +1087,8 @@
   * regardless of case.
   */
 blink { text-decoration: BLINK !IMPORTANT; font-weight: bolder }
+/* Empty url() was causing infinite recursion */
+a { background-image: url(); }
 -->
 </pre>

Index: src/lang-css.js
===================================================================
--- src/lang-css.js (revision 194)
+++ src/lang-css.js (working copy)
@@ -42,7 +42,7 @@
           /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null],
          [PR['PR_STRING'],
           /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null],
-         ['lang-css-str', /^url\(([^\)\"\']*)\)/i],
+         ['lang-css-str', /^url\(([^\)\"\']+)\)/i],
          [PR['PR_KEYWORD'],
           /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,
           null],

Original comment by lannmar...@gmail.com on 6 Dec 2011 at 1:15

GoogleCodeExporter commented 9 years ago
Got ahead of myself in the issue description; "regression" there should be 
"recursion".

Original comment by lannmar...@gmail.com on 6 Dec 2011 at 1:17

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r208.

Original comment by mikesamuel@gmail.com on 30 Mar 2012 at 5:44

GoogleCodeExporter commented 9 years ago
The URL in the description should have been: 
http://code.google.com/p/gerrit/issues/detail?id=1155
(referring to a gerrit bug)

Original comment by lannmar...@gmail.com on 30 Mar 2012 at 5:50