The reason for this is that form field and form tags themselves have Javascript handlers.
The best way to put these in is through the form system. But, the form system sabatoges itself by replacing quotes with UML numbers, e.g. &20;, etc.
As a result, the javascript call fails, and can stop Javascript from working altogether if things just happen to influence each other.

While filtering user input gets help from the fixed value, form generation gets broken.

Here is the following code change:

/**
 * Format an attribute string to insert in a tag.
 *
 * @param $attributes
 *   An associative array of HTML attributes.
 * @return
 *   An HTML string ready for insertion in a tag.
 */
function drupal_attributes($attributes = array(), $quotestyle = ENT_QUOTES) {
  if (is_array($attributes)) {
    $t = '';
    foreach ($attributes as $key => $value) {
        $t .= " $key=".'"'. check_plain($value,$quotestyle) .'"';
    }
    return $t;
  }
}

In conjunction with this, a change to check_plain is required.
And, here is that change:

/**
 * Encode special characters in a plain-text string for display as HTML.
 */
function check_plain($text,$quotestyle = ENT_QUOTES) {
  return htmlspecialchars($text, $quotestyle);
}

Comments

drumm’s picture

Status: Active » Closed (won't fix)

I assume you are talking about the onclick, onchange, and other related attributes. Use of these is discouraged. Javascript and CSS should always be kept in their own separate files. See upload.module for an example. http://docs.jquery.com/ provides documentation on how to attach events using the Javascript library included with Drupal.