mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 06:07:26 +02:00
Add support for proprietary "background" attribute in table elements.
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
39
tests/HTMLPurifier/AttrTransform/BackgroundTest.php
Normal file
39
tests/HTMLPurifier/AttrTransform/BackgroundTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_AttrTransform_BackgroundTest extends HTMLPurifier_AttrTransformHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_AttrTransform_Background();
|
||||
}
|
||||
|
||||
function testEmptyInput() {
|
||||
$this->assertResult( array() );
|
||||
}
|
||||
|
||||
function testBasicTransform() {
|
||||
$this->assertResult(
|
||||
array('background' => 'logo.png'),
|
||||
array('style' => 'background-image:url(logo.png);')
|
||||
);
|
||||
}
|
||||
|
||||
function testPrependNewCSS() {
|
||||
$this->assertResult(
|
||||
array('background' => 'logo.png', 'style' => 'font-weight:bold'),
|
||||
array('style' => 'background-image:url(logo.png);font-weight:bold')
|
||||
);
|
||||
}
|
||||
|
||||
function testLenientTreatmentOfInvalidInput() {
|
||||
// notice that we rely on the CSS validator later to fix this invalid
|
||||
// stuff
|
||||
$this->assertResult(
|
||||
array('background' => 'logo.png);foo:('),
|
||||
array('style' => 'background-image:url(logo.png);foo:();')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
4
tests/HTMLPurifier/HTMLT/tidy-background.htmlt
Normal file
4
tests/HTMLPurifier/HTMLT/tidy-background.htmlt
Normal file
@@ -0,0 +1,4 @@
|
||||
--HTML--
|
||||
<table background="logo.png"><tr><td>asdf</td></tr></table>
|
||||
--EXPECT--
|
||||
<table style="background-image:url(logo.png);"><tr><td>asdf</td></tr></table>
|
Reference in New Issue
Block a user