Open Bug 474877 Opened 16 years ago Updated 12 years ago

Css class names invalid with parenthesis

Categories

(Bugzilla :: Query/Bug List, defect)

x86
Windows XP
defect
Not set
minor

Tracking

()

People

(Reporter: sftw, Unassigned)

References

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 Build Identifier: 3.2 Changing/Adding a Priority of "P5 - (Low)" is converted to reference a CSS class named "bz_P5_&#X28;Low&#X29;" by buglist.cgi. Spaces are replaced with underscores, which I understand. But is there a valid way to create a stylesheet class which will be referenced by this value Bugzilla inserted in the HTML? Reproducible: Always Steps to Reproduce: 1. Create Priority named "P5 - (Low)" or anything with parenthesis (possibly other special characters as well) 2. View HTML from buglist.cgi with a bug using the above Priority 3. Priority is converted to bz_<converted priority value>, but does not seem reference-able in a CSS Actual Results: No stylesheet can be written for this Priority Expected Results: Ability to write a custom stylesheet class for the specific Priority added through Bugzilla's Administration UI Theme did not seem to matter, HTML generated is the same. If the ability to customize the output of a Bugzilla search is a "Major Feature", the severity should be changed.
Version: unspecified → 3.2
Severity: normal → minor
I've always wondered this myself, actually. Does anybody know how you reference those escaped things in CSS?
I did some more testing, and it looks like the parenthesis need to be converted to Unicode instead of Hexadecimal NCRs. Priority: "P5 (Low)" CSS: .bz_P5_\000028Low\000029 { color: blue; } Class Bugzilla should use to reference this style: bz_P5_\000028Low\000029 Even if you wrote a stylesheet to escape the resultant Hexadecimal NCR, it is invalid in the HTML and doesn't work
Given Priority of "P5 (Low)": Bugzilla currently converts to: bz_P5_&#X28;Low&#X29; Needs to convert to: bz_P5\000028Low\000029
We could replace consecutive characters which are not in a whitelist to an underscore. So P5 - (Low) would become P5_-_Low_
This is WFM.I am not able to reproduce it against trunk. It seems comment#5 is already fixed by someone.
This is not WFM. Comment 0 still stands. The CSS validator complains if you pass "bz_P5_&#X28;Low&#X29;" as a class name.
Status: UNCONFIRMED → NEW
Ever confirmed: true
It should noted that (in its current form) css_class_quote does NOT perform substitution for periods ("."), which are not valid class name characters. I believe the following does what comment #5 suggests: > sub css_class_quote { > my ($toencode) = (@_); > $toencode =~ s#[^a-zA-Z0-9_\-.]+#_#g; > return $toencode; > } Unfortunately, such an implementation is English-centric. This would be likely be better (and would probably address comment #3): > sub css_class_quote { > my ($toencode) = (@_); > # Out with the old... > # $toencode =~ s#[ /]#_#g; > # $toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("&#x%x;",ord($1))/eg; > # ...and in with the new (note the '.' has been added to > # the first expression and removed from the second) > $toencode =~ s#[ /.]#_#g; > $toencode =~ s/([^a-zA-Z0-9_\-])/uc sprintf("\\%06x", unpack('U*', $1))/eg; > return $toencode; > }
Actually, one shouldn't escape the class name in HTML. The following should be correct (and should validate): > <?xml version="1.0"?> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> > <head> > <style type="text/css"><!-- > .bz_\000028 POW\000029 {color:red; font-weight:bold;} > --> > </style> > <title>test</title> > </head> > <body> > <p>Ho hum.</p> > <p class="bz_&#x28;POW&#x29;">Paf! Zok!</p> > </body> > </html> Note the spaces though in the CSS. They're needed to signal to the parser the end of a unicode entry.
You need to log in before you can comment on or make changes to this bug.