mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 07:38:41 +00:00
3b26e5dc5b
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@558 48356398-32a2-884e-a903-53898d9a118a
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/ChildDefHarness.php';
|
|
require_once 'HTMLPurifier/ChildDef/Required.php';
|
|
|
|
class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
|
|
{
|
|
|
|
function testParsing() {
|
|
|
|
$def = new HTMLPurifier_ChildDef_Required('foobar | bang |gizmo');
|
|
$this->assertEqual($def->elements,
|
|
array(
|
|
'foobar' => true
|
|
,'bang' => true
|
|
,'gizmo' => true
|
|
));
|
|
|
|
$def = new HTMLPurifier_ChildDef_Required(array('href', 'src'));
|
|
$this->assertEqual($def->elements,
|
|
array(
|
|
'href' => true
|
|
,'src' => true
|
|
));
|
|
|
|
}
|
|
|
|
function testPCDATAForbidden() {
|
|
|
|
$this->obj = new HTMLPurifier_ChildDef_Required('dt | dd');
|
|
|
|
$this->assertResult('', false);
|
|
$this->assertResult(
|
|
'<dt>Term</dt>Text in an illegal location'.
|
|
'<dd>Definition</dd><b>Illegal tag</b>',
|
|
'<dt>Term</dt><dd>Definition</dd>');
|
|
$this->assertResult('How do you do!', false);
|
|
|
|
// whitespace shouldn't trigger it
|
|
$this->assertResult("\n<dd>Definition</dd> ");
|
|
|
|
$this->assertResult(
|
|
'<dd>Definition</dd> <b></b> ',
|
|
'<dd>Definition</dd> '
|
|
);
|
|
$this->assertResult("\t ", false);
|
|
|
|
}
|
|
|
|
function testPCDATAAllowed() {
|
|
|
|
$this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
|
|
|
|
$this->assertResult('<b>Bold text</b><img />', '<b>Bold text</b>');
|
|
|
|
// with child escaping on
|
|
$this->assertResult(
|
|
'<b>Bold text</b><img />',
|
|
'<b>Bold text</b><img />',
|
|
array(
|
|
'Core.EscapeInvalidChildren' => true
|
|
)
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|