[drupal-devel] [bug] Invalid form HTML due to ][ characters not allowed in ID attribute

Steven drupal-devel at drupal.org
Wed May 25 03:45:53 UTC 2005

Issue status update for http://drupal.org/node/23516

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  Thox
 Updated by:   Steven
 Status:       patch

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);


Previous comments:

May 24, 2005 - 15:21 : Thox

Attachment: http://drupal.org/files/issues/form_clean_id.patch (7.96 KB)

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.

More information about the drupal-devel mailing list