diff --git a/NEWS b/NEWS index f52f3525..7365809a 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier 1.6.0, unknown release date ! Support for all deprecated attributes via attribute transformations + bgcolor in td, th, tr and table + + border in img + (incomplete) 1.5.1, unknown release date diff --git a/docs/dev-progress.html b/docs/dev-progress.html index 3e53633c..796d9343 100644 --- a/docs/dev-progress.html +++ b/docs/dev-progress.html @@ -272,7 +272,7 @@ Mozilla on inside and needs -moz-outline, no IE support. bgcolorTABLESuperset style 'background-color' TRSuperset style 'background-color' TD, THSuperset style 'background-color' -borderIMGNear equivalent style 'border-width', as it only applies when link present +borderIMGEquivalent style border:[number]px solid clearBRNear-equiv style 'clear', transform 'all' into 'both' compactDL, OL, ULBoolean, needs custom CSS class; rarely used anyway dirBDORequired, insert ltr (or configuration value) if none diff --git a/library/HTMLPurifier/AttrTransform/Border.php b/library/HTMLPurifier/AttrTransform/Border.php new file mode 100644 index 00000000..0b745d30 --- /dev/null +++ b/library/HTMLPurifier/AttrTransform/Border.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/library/HTMLPurifier/HTMLModule/TransformToStrict.php b/library/HTMLPurifier/HTMLModule/TransformToStrict.php index 275f551d..0660d68e 100644 --- a/library/HTMLPurifier/HTMLModule/TransformToStrict.php +++ b/library/HTMLPurifier/HTMLModule/TransformToStrict.php @@ -9,6 +9,7 @@ require_once 'HTMLPurifier/TagTransform/Font.php'; require_once 'HTMLPurifier/AttrTransform/Lang.php'; require_once 'HTMLPurifier/AttrTransform/TextAlign.php'; require_once 'HTMLPurifier/AttrTransform/BgColor.php'; +require_once 'HTMLPurifier/AttrTransform/Border.php'; /** * Proprietary module that transforms deprecated elements into Strict @@ -22,7 +23,7 @@ class HTMLPurifier_HTMLModule_TransformToStrict extends HTMLPurifier_HTMLModule // we're actually modifying these elements, not defining them var $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', - 'blockquote', 'table', 'td', 'th', 'tr'); + 'blockquote', 'table', 'td', 'th', 'tr', 'img'); var $info_tag_transform = array( // placeholders, see constructor for definitions @@ -80,6 +81,8 @@ class HTMLPurifier_HTMLModule_TransformToStrict extends HTMLPurifier_HTMLModule $this->info['td']->attr_transform_pre['bgcolor'] = $this->info['th']->attr_transform_pre['bgcolor'] = new HTMLPurifier_AttrTransform_BgColor(); + $this->info['img']->attr_transform_pre['border'] = new HTMLPurifier_AttrTransform_Border(); + } var $defines_child_def = true; diff --git a/tests/HTMLPurifier/AttrTransform/BorderTest.php b/tests/HTMLPurifier/AttrTransform/BorderTest.php new file mode 100644 index 00000000..a592e41b --- /dev/null +++ b/tests/HTMLPurifier/AttrTransform/BorderTest.php @@ -0,0 +1,40 @@ +obj = new HTMLPurifier_AttrTransform_Border(); + } + + function test() { + + $this->assertResult( array() ); + + $this->assertResult( + array('border' => '1'), + array('style' => 'border:1px solid;') + ); + + // once again, no validation done here, we expect CSS validator + // to catch it + $this->assertResult( + array('border' => '10%'), + array('style' => 'border:10%px solid;') + ); + + $this->assertResult( + array('border' => '23', 'style' => 'font-weight:bold;'), + array('style' => 'border:23px solid;font-weight:bold;') + ); + + } + +} + +?> \ No newline at end of file diff --git a/tests/test_files.php b/tests/test_files.php index f77b80b4..9806d011 100644 --- a/tests/test_files.php +++ b/tests/test_files.php @@ -35,6 +35,7 @@ $test_files[] = 'AttrDef/URITest.php'; $test_files[] = 'AttrDefTest.php'; $test_files[] = 'AttrTransform/BdoDirTest.php'; $test_files[] = 'AttrTransform/BgColorTest.php'; +$test_files[] = 'AttrTransform/BorderTest.php'; $test_files[] = 'AttrTransform/ImgRequiredTest.php'; $test_files[] = 'AttrTransform/LangTest.php'; $test_files[] = 'AttrTransform/TextAlignTest.php';