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

Implement all "Multiple" CSS properties.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@273 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-08-16 01:39:06 +00:00
parent 2d28380763
commit 3422378c32
3 changed files with 28 additions and 5 deletions

View File

@ -136,9 +136,9 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;}
<tr class="css1 impl-yes"><td>background-color</td><td>COMPOSITE(&lt;color&gt;, transparent)</td></tr> <tr class="css1 impl-yes"><td>background-color</td><td>COMPOSITE(&lt;color&gt;, transparent)</td></tr>
<tr class="css1"><td>background</td><td>SHORTHAND</td></tr> <tr class="css1"><td>background</td><td>SHORTHAND</td></tr>
<tr class="css1"><td>border</td><td>SHORTHAND, MULTIPLE</td></tr> <tr class="css1"><td>border</td><td>SHORTHAND, MULTIPLE</td></tr>
<tr class="css1"><td>border-color</td><td>MULTIPLE</td></tr> <tr class="css1 impl-yes"><td>border-color</td><td>MULTIPLE</td></tr>
<tr class="css1"><td>border-style</td><td>MULTIPLE</td></tr> <tr class="css1 impl-yes"><td>border-style</td><td>MULTIPLE</td></tr>
<tr class="css1"><td>border-width</td><td>MULTIPLE</td></tr> <tr class="css1 impl-yes"><td>border-width</td><td>MULTIPLE</td></tr>
<tr class="css1"><td>border-*</td><td>SHORTHAND</td></tr> <tr class="css1"><td>border-*</td><td>SHORTHAND</td></tr>
<tr class="impl-yes"><td>border-*-color</td><td>COMPOSITE(&lt;color&gt;, transparent)</td></tr> <tr class="impl-yes"><td>border-*-color</td><td>COMPOSITE(&lt;color&gt;, transparent)</td></tr>
<tr class="impl-yes"><td>border-*-style</td><td>ENUM(none, hidden, dotted, dashed, <tr class="impl-yes"><td>border-*-style</td><td>ENUM(none, hidden, dotted, dashed,
@ -168,10 +168,10 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;}
decimal, lower-roman, upper-roman, lower-alpha and upper-alpha. See also decimal, lower-roman, upper-roman, lower-alpha and upper-alpha. See also
CSS 3. Mostly IE lack of support.</td></tr> CSS 3. Mostly IE lack of support.</td></tr>
<tr class="css1"><td>list-style</td><td>SHORTHAND</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 impl-yes"><td>margin</td><td>MULTIPLE</td></tr>
<tr class="css1 impl-yes"><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> &lt;percentage&gt;, auto)</td></tr>
<tr class="css1"><td>padding</td><td>MULTIPLE</td></tr> <tr class="css1 impl-yes"><td>padding</td><td>MULTIPLE</td></tr>
<tr class="css1 impl-yes"><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> &lt;percentage&gt;(positive))</td></tr>
<tr class="css1 impl-yes"><td>text-align</td><td>ENUM(left, right, <tr class="css1 impl-yes"><td>text-align</td><td>ENUM(left, right,

View File

@ -5,6 +5,7 @@ require_once 'HTMLPurifier/AttrDef/Color.php';
require_once 'HTMLPurifier/AttrDef/Composite.php'; require_once 'HTMLPurifier/AttrDef/Composite.php';
require_once 'HTMLPurifier/AttrDef/CSSLength.php'; require_once 'HTMLPurifier/AttrDef/CSSLength.php';
require_once 'HTMLPurifier/AttrDef/Percentage.php'; require_once 'HTMLPurifier/AttrDef/Percentage.php';
require_once 'HTMLPurifier/AttrDef/Multiple.php';
class HTMLPurifier_CSSDefinition class HTMLPurifier_CSSDefinition
{ {
@ -28,12 +29,17 @@ class HTMLPurifier_CSSDefinition
$this->info['text-align'] = new HTMLPurifier_AttrDef_Enum( $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
array('left', 'right', 'center', 'justify'), false); array('left', 'right', 'center', 'justify'), false);
$border_style =
$this->info['border-bottom-style'] = $this->info['border-bottom-style'] =
$this->info['border-right-style'] = $this->info['border-right-style'] =
$this->info['border-left-style'] = $this->info['border-left-style'] =
$this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum( $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum(
array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double', array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
'groove', 'ridge', 'inset', 'outset'), false); 'groove', 'ridge', 'inset', 'outset'), false);
$this->info['border-style'] = new HTMLPurifier_AttrDef_Multiple($border_style);
$this->info['clear'] = new HTMLPurifier_AttrDef_Enum( $this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
array('none', 'left', 'right', 'both'), false); array('none', 'left', 'right', 'both'), false);
$this->info['float'] = new HTMLPurifier_AttrDef_Enum( $this->info['float'] = new HTMLPurifier_AttrDef_Enum(
@ -51,6 +57,7 @@ class HTMLPurifier_CSSDefinition
array('capitalize', 'uppercase', 'lowercase', 'none'), false); array('capitalize', 'uppercase', 'lowercase', 'none'), false);
$this->info['color'] = new HTMLPurifier_AttrDef_Color(); $this->info['color'] = new HTMLPurifier_AttrDef_Color();
$border_color =
$this->info['border-top-color'] = $this->info['border-top-color'] =
$this->info['border-bottom-color'] = $this->info['border-bottom-color'] =
$this->info['border-left-color'] = $this->info['border-left-color'] =
@ -60,6 +67,9 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_Color() new HTMLPurifier_AttrDef_Color()
)); ));
$this->info['border-color'] = new HTMLPurifier_AttrDef_Multiple($border_color);
$border_width =
$this->info['border-top-width'] = $this->info['border-top-width'] =
$this->info['border-bottom-width'] = $this->info['border-bottom-width'] =
$this->info['border-left-width'] = $this->info['border-left-width'] =
@ -68,6 +78,8 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative
)); ));
$this->info['border-width'] = new HTMLPurifier_AttrDef_Multiple($border_width);
$this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array( $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_Enum(array('normal')),
new HTMLPurifier_AttrDef_CSSLength() new HTMLPurifier_AttrDef_CSSLength()
@ -93,6 +105,7 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_Percentage(true) new HTMLPurifier_AttrDef_Percentage(true)
)); ));
$margin =
$this->info['margin-top'] = $this->info['margin-top'] =
$this->info['margin-bottom'] = $this->info['margin-bottom'] =
$this->info['margin-left'] = $this->info['margin-left'] =
@ -102,7 +115,10 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_Enum(array('auto')) new HTMLPurifier_AttrDef_Enum(array('auto'))
)); ));
$this->info['margin'] = new HTMLPurifier_AttrDef_Multiple($margin);
// non-negative // non-negative
$padding =
$this->info['padding-top'] = $this->info['padding-top'] =
$this->info['padding-bottom'] = $this->info['padding-bottom'] =
$this->info['padding-left'] = $this->info['padding-left'] =
@ -111,6 +127,8 @@ class HTMLPurifier_CSSDefinition
new HTMLPurifier_AttrDef_Percentage(true) new HTMLPurifier_AttrDef_Percentage(true)
)); ));
$this->info['padding'] = new HTMLPurifier_AttrDef_Multiple($padding);
$this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array( $this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array(
new HTMLPurifier_AttrDef_CSSLength(), new HTMLPurifier_AttrDef_CSSLength(),
new HTMLPurifier_AttrDef_Percentage() new HTMLPurifier_AttrDef_Percentage()

View File

@ -12,6 +12,7 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
// regular cases, singular // regular cases, singular
$this->assertDef('text-align:right;'); $this->assertDef('text-align:right;');
$this->assertDef('border-left-style:solid;'); $this->assertDef('border-left-style:solid;');
$this->assertDef('border-style:solid dotted;');
$this->assertDef('clear:right;'); $this->assertDef('clear:right;');
$this->assertDef('float:left;'); $this->assertDef('float:left;');
$this->assertDef('font-style:italic;'); $this->assertDef('font-style:italic;');
@ -24,8 +25,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('background-color:transparent;'); $this->assertDef('background-color:transparent;');
$this->assertDef('color:#F00;'); $this->assertDef('color:#F00;');
$this->assertDef('border-top-color:#F00;'); $this->assertDef('border-top-color:#F00;');
$this->assertDef('border-color:#F00 #FF0;');
$this->assertDef('border-top-width:thin;'); $this->assertDef('border-top-width:thin;');
$this->assertDef('border-top-width:12px;'); $this->assertDef('border-top-width:12px;');
$this->assertDef('border-width:5px 1px 4px 2px;');
$this->assertDef('border-top-width:-12px;', false); $this->assertDef('border-top-width:-12px;', false);
$this->assertDef('letter-spacing:normal;'); $this->assertDef('letter-spacing:normal;');
$this->assertDef('letter-spacing:2px;'); $this->assertDef('letter-spacing:2px;');
@ -42,8 +45,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('margin-left:5px;'); $this->assertDef('margin-left:5px;');
$this->assertDef('margin-right:20%;'); $this->assertDef('margin-right:20%;');
$this->assertDef('margin-top:auto;'); $this->assertDef('margin-top:auto;');
$this->assertDef('margin:auto 5%;');
$this->assertDef('padding-bottom:5px;'); $this->assertDef('padding-bottom:5px;');
$this->assertDef('padding-top:20%;'); $this->assertDef('padding-top:20%;');
$this->assertDef('padding:20% 10%;');
$this->assertDef('padding-top:-20%;', false); $this->assertDef('padding-top:-20%;', false);
$this->assertDef('text-indent:3em;'); $this->assertDef('text-indent:3em;');
$this->assertDef('text-indent:5%;'); $this->assertDef('text-indent:5%;');