Escape invalid characters in selector

As per http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier, 
> In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); 

If an element contains a ``[`` or ``]``, the unique selector generated is invalid.
The proposed solution is to escape the brackets in the classname.