1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +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:
Edward Z. Yang
2006-08-02 02:43:52 +00:00
parent 145a51da5a
commit 80281dda55
6 changed files with 53 additions and 34 deletions

View File

@@ -30,6 +30,10 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
$inputs[4] = '<span dir="up-to-down">Bad dir.</span>';
$expect[4] = '<span>Bad dir.</span>';
// test case sensitivity
$inputs[5] = '<div ID="valid">Convert ID to lowercase.</div>';
$expect[5] = '<div id="valid">Convert ID to lowercase.</div>';
$this->assertStrategyWorks($strategy, $inputs, $expect);
}

View File

@@ -48,18 +48,6 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
}
function test_normalizeAttributes() {
$transformer = new HTMLPurifier_TagTransform();
$this->assertEqual(array(), $transformer->normalizeAttributes(array()));
$this->assertEqual(array('class'=>'foo'),
$transformer->normalizeAttributes(array('class'=>'foo')));
$this->assertEqual(array('class'=>'foo'),
$transformer->normalizeAttributes(array('CLASS'=>'foo')));
}
function testSimple() {
$transformer = new HTMLPurifier_TagTransform_Simple('ul');

View File

@@ -0,0 +1,36 @@
<?php
require_once 'HTMLPurifier/Token.php';
class HTMLPurifier_TokenTest extends UnitTestCase
{
function assertTokenConstruction($name, $attributes,
$expect_name = null, $expect_attributes = null
) {
if ($expect_name === null) $expect_name = $name;
if ($expect_attributes === null) $expect_attributes = $attributes;
$token = new HTMLPurifier_Token_Start($name, $attributes);
$this->assertEqual($expect_name, $token->name);
$this->assertEqual($expect_attributes, $token->attributes);
}
function testConstruct() {
// standard case
$this->assertTokenConstruction('a', array('href' => 'about:blank'));
// lowercase the tag's name
$this->assertTokenConstruction('A', array('href' => 'about:blank'),
'a');
// lowercase attributes
$this->assertTokenConstruction('a', array('HREF' => 'about:blank'),
'a', array('href' => 'about:blank'));
}
}
?>