0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-03 05:11:52 +00:00

Implement all composite CSS definitions.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@271 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-08-16 00:18:58 +00:00
parent 490fc003c8
commit 1388beb456
3 changed files with 57 additions and 5 deletions

View File

@ -159,7 +159,7 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;}
100, 200, 300, 400, 500, 600, 700, 800, 900), maybe special code for
in-between integers</td></tr>
<tr class="css1 impl-yes"><td>letter-spacing</td><td>COMPOSITE(&lt;length&gt;, normal)</td></tr>
<tr class="css1"><td>line-height</td><td>COMPOSITE(&lt;number&gt;,
<tr class="css1 impl-yes"><td>line-height</td><td>COMPOSITE(&lt;number&gt;,
&lt;length&gt;, &lt;percentage&gt;, normal)</td></tr>
<tr class="css1 impl-yes"><td>list-style-position</td><td>ENUM(inside, outside),
Strange behavior in browsers</td></tr>
@ -169,21 +169,21 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;}
CSS 3. Mostly IE lack of support.</td></tr>
<tr class="css1"><td>list-style</td><td>SHORTHAND</td></tr>
<tr class="css1"><td>margin</td><td>MULTIPLE</td></tr>
<tr class="css1"><td>margin-*</td><td>COMPOSITE(&lt;length&gt;,
<tr class="css1 impl-yes"><td>margin-*</td><td>COMPOSITE(&lt;length&gt;,
&lt;percentage&gt;, auto)</td></tr>
<tr class="css1"><td>padding</td><td>MULTIPLE</td></tr>
<tr class="css1"><td>padding-*</td><td>COMPOSITE(&lt;length&gt;(positive),
<tr class="css1 impl-yes"><td>padding-*</td><td>COMPOSITE(&lt;length&gt;(positive),
&lt;percentage&gt;(positive))</td></tr>
<tr class="css1 impl-yes"><td>text-align</td><td>ENUM(left, right,
center, justify)</td></tr>
<tr class="css1"><td>text-decoration</td><td>No blink (argh my eyes), not
enum, can be combined (composite sorta): underline, overline,
line-through</td></tr>
<tr class="css1"><td>text-indent</td><td>COMPOSITE(&lt;length&gt;,
<tr class="css1 impl-yes"><td>text-indent</td><td>COMPOSITE(&lt;length&gt;,
&lt;percentage&gt;)</td></tr>
<tr class="css1 impl-yes"><td>text-transform</td><td>ENUM(capitalize, uppercase,
lowercase, none)</td></tr>
<tr class="css1"><td>width</td><td>COMPOSITE(&lt;length&gt;,
<tr class="css1 impl-yes"><td>width</td><td>COMPOSITE(&lt;length&gt;,
&lt;percentage&gt;, auto), Interesting</td></tr>
<tr class="css1 impl-yes"><td>word-spacing</td><td>COMPOSITE(&lt;length&gt;, auto),
IE 5 no support</td></tr>

View File

@ -86,7 +86,41 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_CSSLength()
));
$this->info['line-height'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_Enum(array('normal')),
new HTMLPurifier_AttrDef_Number(true), // no negatives
new HTMLPurifier_AttrDef_CSSLength(true),
new HTMLPurifier_AttrDef_Percentage(true)
));
$this->info['margin-top'] =
$this->info['margin-bottom'] =
$this->info['margin-left'] =
$this->info['margin-right'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_CSSLength(),
new HTMLPurifier_AttrDef_Percentage(),
new HTMLPurifier_AttrDef_Enum(array('auto'))
));
// non-negative
$this->info['padding-top'] =
$this->info['padding-bottom'] =
$this->info['padding-left'] =
$this->info['padding-right'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_CSSLength(true),
new HTMLPurifier_AttrDef_Percentage(true)
));
$this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_CSSLength(),
new HTMLPurifier_AttrDef_Percentage()
));
$this->info['width'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_CSSLength(true),
new HTMLPurifier_AttrDef_Percentage(true),
new HTMLPurifier_AttrDef_Enum(array('auto'))
));
// this could use specialized code
$this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(

View File

@ -34,6 +34,24 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('font-size:200%;');
$this->assertDef('font-size:larger;');
$this->assertDef('font-size:12pt;');
$this->assertDef('line-height:2;');
$this->assertDef('line-height:2em;');
$this->assertDef('line-height:20%;');
$this->assertDef('line-height:normal;');
$this->assertDef('line-height:-20%;', false);
$this->assertDef('margin-left:5px;');
$this->assertDef('margin-right:20%;');
$this->assertDef('margin-top:auto;');
$this->assertDef('padding-bottom:5px;');
$this->assertDef('padding-top:20%;');
$this->assertDef('padding-top:-20%;', false);
$this->assertDef('text-indent:3em;');
$this->assertDef('text-indent:5%;');
$this->assertDef('text-indent:-3em;');
$this->assertDef('width:50%;');
$this->assertDef('width:50px;');
$this->assertDef('width:auto;');
$this->assertDef('width:-50px;', false);
// duplicates
$this->assertDef('text-align:right;text-align:left;',