mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-07 22:56:32 +02:00
Merged r608-621 for 1.3.2 release from trunk.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/1.3@622 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -17,6 +17,9 @@ class HTMLPurifier_AttrDef_LangTest extends HTMLPurifier_AttrDefHarness
|
||||
$this->assertDef(' en ', 'en'); // trim
|
||||
$this->assertDef('EN', 'en'); // case insensitivity
|
||||
|
||||
// (thanks Eugen Pankratz for noticing the typos!)
|
||||
$this->assertDef('En-Us-Edison', 'en-us-edison'); // complex ci
|
||||
|
||||
$this->assertDef('fr en', false); // multiple languages
|
||||
$this->assertDef('%', false); // bad character
|
||||
|
||||
@@ -26,7 +29,7 @@ class HTMLPurifier_AttrDef_LangTest extends HTMLPurifier_AttrDefHarness
|
||||
// primary subtag rules
|
||||
// I'm somewhat hesitant to allow x and i as primary language codes,
|
||||
// because they usually are never used in real life. However,
|
||||
// theoretically speaking, having them alone is permissble, so
|
||||
// theoretically speaking, having them alone is permissable, so
|
||||
// I'll be lenient. No XML parser is going to complain anyway.
|
||||
$this->assertDef('x');
|
||||
$this->assertDef('i');
|
||||
|
@@ -180,6 +180,25 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
|
||||
|
||||
}
|
||||
|
||||
function test_create() {
|
||||
|
||||
HTMLPurifier_ConfigSchema::defineNamespace('Cake', 'Properties of it.');
|
||||
HTMLPurifier_ConfigSchema::define('Cake', 'Sprinkles', 666, 'int', 'Number of.');
|
||||
HTMLPurifier_ConfigSchema::define('Cake', 'Flavor', 'vanilla', 'string', 'Flavor of the batter.');
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('Cake', 'Sprinkles', 42);
|
||||
|
||||
// test flat pass-through
|
||||
$created_config = HTMLPurifier_Config::create($config);
|
||||
$this->assertEqual($config, $created_config);
|
||||
|
||||
// test loadArray
|
||||
$created_config = HTMLPurifier_Config::create(array('Cake.Sprinkles' => 42));
|
||||
$this->assertEqual($config, $created_config);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -25,7 +25,7 @@ class HTMLPurifier_Test extends UnitTestCase
|
||||
function testStrict() {
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('HTML', 'Strict', true);
|
||||
$this->purifier = new HTMLPurifier($config);
|
||||
$this->purifier = new HTMLPurifier( $config ); // verbose syntax
|
||||
|
||||
$this->assertPurification(
|
||||
'<u>Illegal underline</u>',
|
||||
@@ -40,10 +40,11 @@ class HTMLPurifier_Test extends UnitTestCase
|
||||
}
|
||||
|
||||
function testDifferentAllowedElements() {
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('HTML', 'AllowedElements', array('b', 'i', 'p', 'a'));
|
||||
$config->set('HTML', 'AllowedAttributes', array('a.href', '*.id'));
|
||||
$this->purifier = new HTMLPurifier($config);
|
||||
|
||||
$this->purifier = new HTMLPurifier(array(
|
||||
'HTML.AllowedElements' => array('b', 'i', 'p', 'a'),
|
||||
'HTML.AllowedAttributes' => array('a.href', '*.id')
|
||||
));
|
||||
|
||||
$this->assertPurification(
|
||||
'<p>Par.</p><p>Para<a href="http://google.com/">gr</a>aph</p>Text<b>Bol<i>d</i></b>'
|
||||
@@ -58,9 +59,7 @@ class HTMLPurifier_Test extends UnitTestCase
|
||||
|
||||
function testDisableURI() {
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('Attr', 'DisableURI', true);
|
||||
$this->purifier = new HTMLPurifier($config);
|
||||
$this->purifier = new HTMLPurifier( array('Attr.DisableURI' => true) );
|
||||
|
||||
$this->assertPurification(
|
||||
'<img src="foobar"/>',
|
||||
@@ -69,6 +68,21 @@ class HTMLPurifier_Test extends UnitTestCase
|
||||
|
||||
}
|
||||
|
||||
function test_purifyArray() {
|
||||
|
||||
$this->purifier = new HTMLPurifier();
|
||||
|
||||
$this->assertEqual(
|
||||
$this->purifier->purifyArray(
|
||||
array('Good', '<b>Sketchy', 'foo' => '<script>bad</script>')
|
||||
),
|
||||
array('Good', '<b>Sketchy</b>', 'foo' => 'bad')
|
||||
);
|
||||
|
||||
$this->assertIsA($this->purifier->context, 'array');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user