mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
[1.2.0] [BC] ID attributes now disabled by default. New directives:
+ %HTML.EnableAttrID - restores old behavior by allowing IDs + %Attr.IDPrefix - %Attr.IDBlacklist alternative that munges all user IDs so that they don't collide with your IDs + %Attr.IDPrefixLocal - Same as above, but for when there are multiple instances of user content on the page + Profuse documentation on how to use these available in id.txt git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@526 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -21,17 +21,25 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
|
||||
$this->assertResult('');
|
||||
|
||||
// test ids
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>');
|
||||
$this->assertResult(
|
||||
'<div id="valid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
);
|
||||
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>', true,
|
||||
array('HTML.EnableAttrID' => true));
|
||||
|
||||
$this->assertResult(
|
||||
'<div id="0invalid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
'<div>Kill the ID.</div>',
|
||||
array('HTML.EnableAttrID' => true)
|
||||
);
|
||||
|
||||
// test id accumulator
|
||||
$this->assertResult(
|
||||
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
|
||||
'<div id="valid">Valid</div><div>Invalid</div>'
|
||||
'<div id="valid">Valid</div><div>Invalid</div>',
|
||||
array('HTML.EnableAttrID' => true)
|
||||
);
|
||||
|
||||
$this->assertResult(
|
||||
@@ -42,20 +50,25 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
|
||||
// test attribute key case sensitivity
|
||||
$this->assertResult(
|
||||
'<div ID="valid">Convert ID to lowercase.</div>',
|
||||
'<div id="valid">Convert ID to lowercase.</div>'
|
||||
'<div id="valid">Convert ID to lowercase.</div>',
|
||||
array('HTML.EnableAttrID' => true)
|
||||
);
|
||||
|
||||
// test simple attribute substitution
|
||||
$this->assertResult(
|
||||
'<div id=" valid ">Trim whitespace.</div>',
|
||||
'<div id="valid">Trim whitespace.</div>'
|
||||
'<div id="valid">Trim whitespace.</div>',
|
||||
array('HTML.EnableAttrID' => true)
|
||||
);
|
||||
|
||||
// test configuration id blacklist
|
||||
$this->assertResult(
|
||||
'<div id="invalid">Invalid</div>',
|
||||
'<div>Invalid</div>',
|
||||
array('Attr.IDBlacklist' => array('invalid'))
|
||||
array(
|
||||
'Attr.IDBlacklist' => array('invalid'),
|
||||
'HTML.EnableAttrID' => true
|
||||
)
|
||||
);
|
||||
|
||||
// test classes
|
||||
|
Reference in New Issue
Block a user