mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Handle CRLF discrepancies
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -1,62 +1,62 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('Attr', 'EnableID', true);
|
||||
}
|
||||
|
||||
|
||||
function testPreserveIDWhenEnabled() {
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>');
|
||||
}
|
||||
|
||||
function testRemoveInvalidID() {
|
||||
$this->assertResult(
|
||||
'<div id="0invalid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveDuplicateID() {
|
||||
$this->assertResult(
|
||||
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
|
||||
'<div id="valid">Valid</div><div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testAttributeKeyCaseInsensitivity() {
|
||||
$this->assertResult(
|
||||
'<div ID="valid">Convert ID to lowercase.</div>',
|
||||
'<div id="valid">Convert ID to lowercase.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTrimWhitespace() {
|
||||
$this->assertResult(
|
||||
'<div id=" valid ">Trim whitespace.</div>',
|
||||
'<div id="valid">Trim whitespace.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIDBlacklist() {
|
||||
$this->config->set('Attr', 'IDBlacklist', array('invalid'));
|
||||
$this->assertResult(
|
||||
'<div id="invalid">Invalid</div>',
|
||||
'<div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNameConvertedToID() {
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
$this->assertResult(
|
||||
'<a name="foobar" />',
|
||||
'<a id="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('Attr', 'EnableID', true);
|
||||
}
|
||||
|
||||
|
||||
function testPreserveIDWhenEnabled() {
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>');
|
||||
}
|
||||
|
||||
function testRemoveInvalidID() {
|
||||
$this->assertResult(
|
||||
'<div id="0invalid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveDuplicateID() {
|
||||
$this->assertResult(
|
||||
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
|
||||
'<div id="valid">Valid</div><div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testAttributeKeyCaseInsensitivity() {
|
||||
$this->assertResult(
|
||||
'<div ID="valid">Convert ID to lowercase.</div>',
|
||||
'<div id="valid">Convert ID to lowercase.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTrimWhitespace() {
|
||||
$this->assertResult(
|
||||
'<div id=" valid ">Trim whitespace.</div>',
|
||||
'<div id="valid">Trim whitespace.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIDBlacklist() {
|
||||
$this->config->set('Attr', 'IDBlacklist', array('invalid'));
|
||||
$this->assertResult(
|
||||
'<div id="invalid">Invalid</div>',
|
||||
'<div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNameConvertedToID() {
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
$this->assertResult(
|
||||
'<a name="foobar" />',
|
||||
'<a id="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user