Skip Menu |

This queue is for tickets about the CSS-SAC CPAN distribution.

Report information
The Basics
Id: 18586
Status: new
Priority: 0/
Queue: CSS-SAC

People
Owner: Nobody in particular
Requestors: Rene
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.06
Fixed in: (no value)



Subject: When curly braces are unbalanced, program enters endless loop
When CSS contains something like this: body { color: black h1 { color: green } ...then the program fails to extract the rule using Text::Balanced:: extract_bracketed, which will return an empty string + the $css variable will remain unchanged. But the code does not check, if the rule is empty string, it assumes all is fine, and continues to parse next selector. But of course there is no selector to be found - so it reports an element selector with no name defined. And it again reaches this point, where it uses Text::Balanced... and it loops... loops... loops... and loads of universal selectors are found... I have fixed it for myself with the following code. Not sure how correct it is: ($rule,$css,undef) = Text::Balanced::extract_bracketed($css,q/{}"/,qr/\s */); #" # if Text::Balanced returned an empty string, this means, it failed to match # the final closing parenthesis '}'. if ( $rule eq '' ) { # try to skip into next closing parenthesis if ( $css =~ s/^[^}]*}// ) { $sac->[_eh_]->warning('Curly braces not balanced. Skipping to next "}"'); } else { $sac->[_eh_]->fatal_error('Unable to match closing "}"'); } } else { $sac->parse_rule(\$rule); }