diff --git a/docs/progress.html b/docs/progress.html index d3faab2d..a5bbf2ba 100644 --- a/docs/progress.html +++ b/docs/progress.html @@ -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 letter-spacingCOMPOSITE(<length>, normal) -line-heightCOMPOSITE(<number>, +line-heightCOMPOSITE(<number>, <length>, <percentage>, normal) list-style-positionENUM(inside, outside), Strange behavior in browsers @@ -169,21 +169,21 @@ thead th {text-align:left;padding:0.1em;background-color:#EEE;} CSS 3. Mostly IE lack of support. list-styleSHORTHAND marginMULTIPLE -margin-*COMPOSITE(<length>, +margin-*COMPOSITE(<length>, <percentage>, auto) paddingMULTIPLE -padding-*COMPOSITE(<length>(positive), +padding-*COMPOSITE(<length>(positive), <percentage>(positive)) text-alignENUM(left, right, center, justify) text-decorationNo blink (argh my eyes), not enum, can be combined (composite sorta): underline, overline, line-through -text-indentCOMPOSITE(<length>, +text-indentCOMPOSITE(<length>, <percentage>) text-transformENUM(capitalize, uppercase, lowercase, none) -widthCOMPOSITE(<length>, +widthCOMPOSITE(<length>, <percentage>, auto), Interesting word-spacingCOMPOSITE(<length>, auto), IE 5 no support diff --git a/library/HTMLPurifier/CSSDefinition.php b/library/HTMLPurifier/CSSDefinition.php index 72eb34fa..105a6797 100644 --- a/library/HTMLPurifier/CSSDefinition.php +++ b/library/HTMLPurifier/CSSDefinition.php @@ -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( diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index 36eecfbb..aff1d656 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -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;',