diff --git a/library/HTMLPurifier/AttrDef/Pixels.php b/library/HTMLPurifier/AttrDef/Pixels.php new file mode 100644 index 00000000..4c04a855 --- /dev/null +++ b/library/HTMLPurifier/AttrDef/Pixels.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php index 5ead680b..a94b2b56 100644 --- a/library/HTMLPurifier/Config.php +++ b/library/HTMLPurifier/Config.php @@ -35,6 +35,10 @@ class HTMLPurifier_Config // at all. var $attr_lang_alpha = false; + // max amount of pixels allowed to be specified + var $attr_pixels_hmax = 600; // horizontal context + var $attr_pixels_vmax = 1200; // vertical context + function createDefault() { $config = new HTMLPurifier_Config(); return $config; diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php index 964bc672..0fe46332 100644 --- a/library/HTMLPurifier/Definition.php +++ b/library/HTMLPurifier/Definition.php @@ -6,6 +6,7 @@ require_once 'HTMLPurifier/AttrDef.php'; require_once 'HTMLPurifier/AttrDef/Class.php'; require_once 'HTMLPurifier/AttrDef/Text.php'; require_once 'HTMLPurifier/AttrDef/Lang.php'; + require_once 'HTMLPurifier/AttrDef/Pixels.php'; require_once 'HTMLPurifier/AttrTransform.php'; require_once 'HTMLPurifier/AttrTransform/Lang.php'; require_once 'HTMLPurifier/AttrTransform/TextAlign.php'; @@ -296,6 +297,8 @@ class HTMLPurifier_Definition $this->info['table']->attr['rules'] = $e_TRules; $this->info['table']->attr['summary'] = $e_Text; + $this->info['table']->attr['border'] = new HTMLPurifier_AttrDef_Pixels(); + ////////////////////////////////////////////////////////////////////// // UNIMP : info_tag_transform : transformations of tags diff --git a/tests/HTMLPurifier/AttrDef/PixelsTest.php b/tests/HTMLPurifier/AttrDef/PixelsTest.php new file mode 100644 index 00000000..ad62235b --- /dev/null +++ b/tests/HTMLPurifier/AttrDef/PixelsTest.php @@ -0,0 +1,39 @@ +def = new HTMLPurifier_AttrDef_Pixels(); + + $this->assertDef('1'); + $this->assertDef('0'); + + $this->assertDef('2px', '2'); // rm px suffix + + $this->assertDef('dfs', false); // totally invalid value + + // conceivably we could repair this value, but we won't for now + $this->assertDef('9in', false); + + // test trim + $this->assertDef(' 45 ', '45'); + + // no negatives + $this->assertDef('-2', '0'); + + // remove empty + $this->assertDef('', false); + + // round down + $this->assertDef('4.9', '4'); + + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php index 6adbb66e..17d6ba08 100644 --- a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php +++ b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php @@ -69,7 +69,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends // test table $inputs[13] = << +
Supercalifragilistic |
---|