From d429989f86f765df865d6baf6ca89273868bbbe8 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 6 Aug 2006 01:41:18 +0000 Subject: [PATCH] Implement MultiLength. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@173 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier/AttrDef/MultiLength.php | 36 +++++++++++++++++++ library/HTMLPurifier/Definition.php | 5 +++ .../HTMLPurifier/AttrDef/MultiLengthTest.php | 31 ++++++++++++++++ .../Strategy/ValidateAttributesTest.php | 4 +-- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 library/HTMLPurifier/AttrDef/MultiLength.php create mode 100644 tests/HTMLPurifier/AttrDef/MultiLengthTest.php diff --git a/library/HTMLPurifier/AttrDef/MultiLength.php b/library/HTMLPurifier/AttrDef/MultiLength.php new file mode 100644 index 00000000..f5441fbb --- /dev/null +++ b/library/HTMLPurifier/AttrDef/MultiLength.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php index a8766927..60f48a36 100644 --- a/library/HTMLPurifier/Definition.php +++ b/library/HTMLPurifier/Definition.php @@ -8,6 +8,7 @@ require_once 'HTMLPurifier/AttrDef.php'; require_once 'HTMLPurifier/AttrDef/Lang.php'; require_once 'HTMLPurifier/AttrDef/Pixels.php'; require_once 'HTMLPurifier/AttrDef/Length.php'; + require_once 'HTMLPurifier/AttrDef/MultiLength.php'; require_once 'HTMLPurifier/AttrTransform.php'; require_once 'HTMLPurifier/AttrTransform/Lang.php'; require_once 'HTMLPurifier/AttrTransform/TextAlign.php'; @@ -296,6 +297,10 @@ class HTMLPurifier_Definition $this->info['img']->attr['height'] = $e_Length; $this->info['img']->attr['width'] = $e_Length; + $e_MultiLength = new HTMLPurifier_AttrDef_MultiLength(); + $this->info['col']->attr['width'] = $e_MultiLength; + $this->info['colgroup']->attr['width'] = $e_MultiLength; + ////////////////////////////////////////////////////////////////////// // UNIMP : info_tag_transform : transformations of tags diff --git a/tests/HTMLPurifier/AttrDef/MultiLengthTest.php b/tests/HTMLPurifier/AttrDef/MultiLengthTest.php new file mode 100644 index 00000000..6d9acd36 --- /dev/null +++ b/tests/HTMLPurifier/AttrDef/MultiLengthTest.php @@ -0,0 +1,31 @@ +def = new HTMLPurifier_AttrDef_MultiLength(); + } + + function test() { + + // length check + parent::test(); + + $this->assertDef('*'); + $this->assertDef('1*'); + $this->assertDef('56*'); + + $this->assertDef('**', false); // plain old bad + + $this->assertDef('5.4*', '5*'); // no decimals + $this->assertDef('-3*', false); // no negatives + + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php index 5b8650cb..d56152ef 100644 --- a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php +++ b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php @@ -70,8 +70,8 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends // test table $inputs[13] = << - - + + Fiddly name Super-duper-price