commit dda60c058a1078e33cedf9d5bfde9ecc48f56bb5 Author: Joel Pittet Date: Sun Jun 9 23:09:59 2013 -0700 add attribute name check diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index ac94cab..b84cc79 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -63,18 +63,16 @@ public function offsetGet($name) { * Implements ArrayAccess::offsetSet(). */ public function offsetSet($name, $value) { - $value = $this->createAttributeValue($name, $value); - $this->storage[$name] = $value; + $this->storage[$name] = $this->createAttributeValue($name, $value); } /** * Creates the different types of attribute values. * @param string $name - * @todo + * The attribute name. * @param mixed $value - * @todo + * The attribute value. * @return object - * */ protected function createAttributeValue($name, $value) { if (is_array($value)) { @@ -110,7 +108,7 @@ public function __toString() { $return = ''; foreach ($this->storage as $name => $value) { if (!$value->printed()) { - $rendered = is_object($value) ? $value->render() : (check_plain($name) . ' = "' . check_plain($value) . '"'); + $rendered = $value->render(); if ($rendered) { $return .= ' ' . $rendered; } @@ -124,9 +122,7 @@ public function __toString() { */ public function __clone() { foreach ($this->storage as $name => $value) { - if (is_object($value)) { - $this->storage[$name] = clone $value; - } + $this->storage[$name] = clone $value; } } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index f63a19a..aaea6bb 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -483,15 +483,12 @@ function rdf_preprocess_html(&$variables) { // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix // attribute inside the html element. $prefixes = array(); - // debug($variables['html_attributes']['prefix']); if (!isset($variables['html_attributes']['prefix'])) { $variables['html_attributes']['prefix'] = array(); } foreach(rdf_get_namespaces() as $prefix => $uri) { - // debug($prefix); $variables['html_attributes']['prefix'][] = $prefix . ': ' . $uri . "\n"; } - // debug($variables['html_attributes']['prefix']); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/AttributesUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/AttributesUnitTest.php index c561529..c28f675 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/AttributesUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/AttributesUnitTest.php @@ -27,6 +27,7 @@ public static function getInfo() { */ function testDrupalAttributes() { // Verify that special characters are HTML encoded. + $this->assertIdentical((string) new Attribute(array('&"\'<>' => 'value')), ' &"'<>="value"', 'HTML encode attribute names.'); $this->assertIdentical((string) new Attribute(array('title' => '&"\'<>')), ' title="&"'<>"', 'HTML encode attribute values.'); // Verify multi-value attributes are concatenated with spaces.