-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
CSS file of 320 bytes takes 10+ seconds to parse #18
Comments
Thanks for the report. I welcome investigation or a patch. |
No patch at the moment, but I believe this is related to backtracking in the regular expressions parsing strings, for the specific input shared. The lengthy call is located at cssutils/cssutils/tokenize2.py Line 172 in d9d2bdc
When the input is cssutils/cssutils/cssproductions.py Line 32 in d9d2bdc
|
This can be fixed by rewriting the string productions ( |
I'd prefer to see a rewrite of the string productions, especially if it can be done in a fairly straightforward way and without adding to much complication to the approach. |
I've encountered CSS file which
cssutils
library takes lots of seconds to parse (in fact, almost infinite).After some investigation I've minified problematic sample (as possible) and prepared reproducible code example.
On my laptop (core i7-8550U) it takes 14 seconds to parse file with just one line and 320 bytes of text.
Original file has 20kBytes of text and parser does not finish it in several hours.
Code:
https://gist.github.com/vdmit/ef9007170fa1c616cf5aba1fcebfce87
I'm using:
cssutils
release 2.3.0 from pypi repoNotes:
.s11...
reduces execution time from 14 seconds to 3 seconds).So, there is a exponential complexity somewhere, which is strange.
Traceback of interrupted script is following:
The text was updated successfully, but these errors were encountered: