mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Fix case-sensitivity issues for attributes. Added TokenTest. Updated TODO. Removed TagTransform::normalizeAttributes
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@142 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -9,21 +9,6 @@ class HTMLPurifier_TagTransform
|
||||
trigger_error('Call to abstract function', E_USER_ERROR);
|
||||
}
|
||||
|
||||
function normalizeAttributes($attributes) {
|
||||
$keys = array_keys($attributes);
|
||||
foreach ($keys as $key) {
|
||||
// normalization only necessary when key is not lowercase
|
||||
if (!ctype_lower($key)) {
|
||||
$new_key = strtolower($key);
|
||||
if (!isset($attributes[$new_key])) {
|
||||
$attributes[$new_key] = $attributes[$key];
|
||||
}
|
||||
unset($attributes[$key]);
|
||||
}
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform
|
||||
@@ -60,7 +45,7 @@ class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform
|
||||
class HTMLPurifier_TagTransform_Center extends HTMLPurifier_TagTransform
|
||||
{
|
||||
function transform($tag) {
|
||||
$attributes = $this->normalizeAttributes($tag->attributes);
|
||||
$attributes = $tag->attributes;
|
||||
$prepend_css = 'text-align:center;';
|
||||
if (isset($attributes['style'])) {
|
||||
$attributes['style'] = $prepend_css . $attributes['style'];
|
||||
|
@@ -52,6 +52,16 @@ class HTMLPurifier_Token_Tag extends HTMLPurifier_Token // abstract
|
||||
*/
|
||||
function HTMLPurifier_Token_Tag($name, $attributes = array()) {
|
||||
$this->name = ctype_lower($name) ? $name : strtolower($name);
|
||||
foreach ($attributes as $key => $value) {
|
||||
// normalization only necessary when key is not lowercase
|
||||
if (!ctype_lower($key)) {
|
||||
$new_key = strtolower($key);
|
||||
if (!isset($attributes[$new_key])) {
|
||||
$attributes[$new_key] = $attributes[$key];
|
||||
}
|
||||
unset($attributes[$key]);
|
||||
}
|
||||
}
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user