diff --git a/docs/code-quality.txt b/docs/code-quality.txt index c8b4b8c3..33751ca4 100644 --- a/docs/code-quality.txt +++ b/docs/code-quality.txt @@ -20,6 +20,7 @@ AttrDef out for mailto scheme, IPv6 validation is broken (fringe), unintuitive variable overwriting, missing validation for query, fragment and path, no percent-encode fixing + CSS - parser doesn't accept advanced CSS (fringe) AttrTransform - doesn't accept AttrContext, non-validating Lang - invalid xml:lang value can overwrite valid lang value (fringe) ChildDef - not-allowed nodes translated to text, likely invalid handling diff --git a/docs/progress.html b/docs/progress.html index 06913f68..8ab1adf3 100644 --- a/docs/progress.html +++ b/docs/progress.html @@ -161,7 +161,7 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;} margin-*- padding- padding-*- -text-align- +text-align- text-decorationNo blink (argh my eyes) text-indent- text-transform- diff --git a/library/HTMLPurifier/AttrDef/CSS.php b/library/HTMLPurifier/AttrDef/CSS.php new file mode 100644 index 00000000..9a0f60ff --- /dev/null +++ b/library/HTMLPurifier/AttrDef/CSS.php @@ -0,0 +1,35 @@ +info[$property])) continue; + $result = $definition->info[$property]->validate($value,$config,$context); + if ($result === false) continue; + $new_declarations .= "$property:$result;"; + } + + return $new_declarations ? $new_declarations : false; + + } + +} + +?> \ No newline at end of file diff --git a/library/HTMLPurifier/CSSDefinition.php b/library/HTMLPurifier/CSSDefinition.php new file mode 100644 index 00000000..e47b8de3 --- /dev/null +++ b/library/HTMLPurifier/CSSDefinition.php @@ -0,0 +1,30 @@ +setup(); + } + return $instance; + } + + function HTMLPurifier_CSSDefinition() {} + + function setup() { + + $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum( + array('left', 'right', 'center', 'justify'), false); + + } + +} + +?> \ No newline at end of file diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php index 418f04c7..9ae93b9f 100644 --- a/library/HTMLPurifier/Definition.php +++ b/library/HTMLPurifier/Definition.php @@ -255,6 +255,7 @@ class HTMLPurifier_Definition 'id' => new HTMLPurifier_AttrDef_ID(), 'class' => new HTMLPurifier_AttrDef_Class(), 'title' => $e_Text, + 'style' => new HTMLPurifier_AttrDef_CSS(), // i18n 'dir' => new HTMLPurifier_AttrDef_Enum(array('ltr','rtl'), false), 'lang' => new HTMLPurifier_AttrDef_Lang(), diff --git a/library/HTMLPurifier/Generator.php b/library/HTMLPurifier/Generator.php index 19295dbc..1d2cdaab 100644 --- a/library/HTMLPurifier/Generator.php +++ b/library/HTMLPurifier/Generator.php @@ -1,5 +1,7 @@ def = new HTMLPurifier_AttrDef_CSS(); + + $this->assertDef('text-align:right;'); + + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php index ff1488f4..beb847dc 100644 --- a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php +++ b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php @@ -64,8 +64,8 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends $expect[11] = 'La soupe.'; // test align (won't work till CSS validation is implemented) - // $inputs[12] = '

Centered Headline

'; - // $expect[12] = '

Centered Headline

'; + $inputs[12] = '

Centered Headline

'; + $expect[12] = '

Centered Headline

'; // test table $inputs[13] = <<