#1 CSS::SAC error when underscores in #id_selectors

open
nobody
None
5
2006-02-06
2006-02-06
Rene Saarsoo
No

The CSS::SAC parser does not understand, that the #id
selectors
can have underscores inside them. So, when you give the
following
CSS to the parser:

#foo_bar {font-variant: cursive}

it will give you fatal error:

[fatal] Unknown token in simple selector (line 992) at
/usr/lib/perl5/site_perl/5.8.7/CSS/SAC.pm line 1379.

I changed the line 45 in "SAC.pm", to include the
underscore character:

# matches a name token
$RE_NAME = qr/
- (?:(?:\\(?:(?:[a-fA-F0-9]{1,6}[\t\x20])
|[\x32-\xff]))|[a-zA-Z\x80-\xff0-9-])+
+ (?:(?:\\(?:(?:[a-fA-F0-9]{1,6}[\t\x20])
|[\x32-\xff]))|[a-zA-Z\x80-\xff0-9_-])+
/xs;

It seems to work for me now as intended.

Discussion