Attached patch makes Drupal forms slightly more valid. It removes "][" from ID attributes in forms and replaces it with a dash (-).

In the future, we might clean out more characters, but these ones are used throughout Drupal.

CommentFileSizeAuthor
form_clean_id.patch7.96 KBThox

Comments

Steven’s picture

Applied to HEAD. Good catch. We had a similar problem with aggregator blocks, they used ':' in the id, which messed up CSS selecting (as : is for CSS pseudoclasses like :hover).

Perhaps we should use a regular expression which replaces anything that strips anything that is not a letter, number or dash? like:

preg_replace('[^A-Za-z0-9_-]+', '-', $id);
dries’s picture

Anonymous’s picture

jasoncd’s picture

Version: » 4.6.4

Excuse me if I'm being ignorant (first post), but it doesn't look fixed to me. In 4.6.2 to 4.6.4, the ][ are still there. For an example, look at the admin pages for access control and modules (checkboxes).

chx’s picture

Steven said "applied to HEAD" not "applied to HEAD and 4.6.x"...