mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 17:01:51 +00:00
0ea04db559
- Migrated most unit tests over to XHTML 1.0 Strict to preserve transformation behavior - Created %Core.ColorKeywords to be shared between CSS_Color and HTML_Color - Added AttrDef_HTML_Color as AttrType Color - HTMLPurifier_Config::create(HTMLPurifier_Config $config) now clones the object - Attribute minimization for HTML implemented in Generator - Move div@align fix from proprietary to regular set - Color keywords now map to full six digit hexadecimal codes - Harness will now tack on per-use-case configuration git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1084 48356398-32a2-884e-a903-53898d9a118a
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/StrategyHarness.php';
|
|
require_once 'HTMLPurifier/Strategy/RemoveForeignElements.php';
|
|
|
|
class HTMLPurifier_Strategy_RemoveForeignElementsTest
|
|
extends HTMLPurifier_StrategyHarness
|
|
{
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
|
|
}
|
|
|
|
function test() {
|
|
|
|
$this->config = array('HTML.Doctype' => 'XHTML 1.0 Strict');
|
|
|
|
$this->assertResult('');
|
|
|
|
$this->assertResult('This is <b>bold text</b>.');
|
|
|
|
$this->assertResult(
|
|
'<asdf>Bling</asdf><d href="bang">Bong</d><foobar />',
|
|
'BlingBong'
|
|
);
|
|
|
|
$this->assertResult(
|
|
'<menu><li>Item 1</li></menu>',
|
|
'<ul><li>Item 1</li></ul>'
|
|
);
|
|
|
|
// test center transform
|
|
$this->assertResult(
|
|
'<center>Look I am Centered!</center>',
|
|
'<div style="text-align:center;">Look I am Centered!</div>'
|
|
);
|
|
|
|
// test font transform
|
|
$this->assertResult(
|
|
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
|
'<span style="color:red;font-family:Arial;font-size:xx-large;">Big'.
|
|
' Warning!</span>'
|
|
);
|
|
|
|
// test removal of invalid img tag
|
|
$this->assertResult(
|
|
'<img />',
|
|
''
|
|
);
|
|
|
|
// test preservation of valid img tag
|
|
$this->assertResult('<img src="foobar.gif" />');
|
|
|
|
// test preservation of invalid img tag when removal is disabled
|
|
$this->assertResult(
|
|
'<img />',
|
|
true,
|
|
array(
|
|
'Core.RemoveInvalidImg' => false
|
|
)
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|