Problem/Motivation

drupal_clean_css_identifier() ostensibly provides valid CSS identifiers as per the CSS Spec, however it only strips out illegal symbols. Currently it will allow numeric identifiers, or those starting with numbers, which is not valid (see http://www.w3.org/TR/CSS21/syndata.html#characters).

There may be other things it needs to do as well.

Proposed resolution

Update the function to:

  1. flush out or prefix invalid numeric identifiers

Remaining tasks

User interface changes

API changes

Comments

larowlan’s picture

Issue tags: +Needs tests, +Novice

Adding tags

maartendeblock’s picture

Status: Active » Needs review
StatusFileSize
new684 bytes

This patch makes sure the identifier can't start with a digit, two hyphens, or a hyphen followed by a digit. The characters are replaced by _ or __.

maartendeblock’s picture

Issue summary: View changes

Add link to CSS spec

enhdless’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Patch applies great!

star-szr’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for checking it out @enhdless, this does still need tests though. Back to needs work for that reason.

dsdeiz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB
new2.1 KB

Hi!

Not sure if I got this right. Attached are the patches with failing and succeeding tests.

dsdeiz’s picture

Sorry, wrong patches. Attached now.

The last submitted patch, 5: drupal-2073123-5-css-identifier-failing.patch, failed testing.

The last submitted patch, 6: drupal-2073123-6-css-identifier-failing.patch, failed testing.

star-szr’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Looks great to me, thanks @dsdeiz!

enhdless’s picture

Yep, patch works nicely.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Good catch!

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.