0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-08 14:58:42 +00:00

feat: Add support for all text-decoration properties (#360)

* CSS: add support for all text-decoration related properties

* updated arrays to use short syntex

Co-authored-by: Raheel Hasan <raheel.hasan@luciditysoftware.com.au>
This commit is contained in:
Raheel Hsn 2023-01-13 00:41:13 +11:00 committed by GitHub
parent da35a5e0d7
commit 2d775c0187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 91 deletions

View File

@ -13,7 +13,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
* Assoc array of attribute name to definition object. * Assoc array of attribute name to definition object.
* @type HTMLPurifier_AttrDef[] * @type HTMLPurifier_AttrDef[]
*/ */
public $info = array(); public $info = [];
/** /**
* Constructs the info array. The meat of this class. * Constructs the info array. The meat of this class.
@ -22,7 +22,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
protected function doSetup($config) protected function doSetup($config)
{ {
$this->info['text-align'] = new HTMLPurifier_AttrDef_Enum( $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
array('left', 'right', 'center', 'justify'), ['left', 'right', 'center', 'justify'],
false false
); );
@ -31,7 +31,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$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', 'none',
'hidden', 'hidden',
'dotted', 'dotted',
@ -42,42 +42,42 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'ridge', 'ridge',
'inset', 'inset',
'outset' 'outset'
), ],
false false
); );
$this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style);
$this->info['clear'] = new HTMLPurifier_AttrDef_Enum( $this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
array('none', 'left', 'right', 'both'), ['none', 'left', 'right', 'both'],
false false
); );
$this->info['float'] = new HTMLPurifier_AttrDef_Enum( $this->info['float'] = new HTMLPurifier_AttrDef_Enum(
array('none', 'left', 'right'), ['none', 'left', 'right'],
false false
); );
$this->info['font-style'] = new HTMLPurifier_AttrDef_Enum( $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum(
array('normal', 'italic', 'oblique'), ['normal', 'italic', 'oblique'],
false false
); );
$this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum(
array('normal', 'small-caps'), ['normal', 'small-caps'],
false false
); );
$uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('none')), new HTMLPurifier_AttrDef_Enum(['none']),
new HTMLPurifier_AttrDef_CSS_URI() new HTMLPurifier_AttrDef_CSS_URI()
) ]
); );
$this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum( $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum(
array('inside', 'outside'), ['inside', 'outside'],
false false
); );
$this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum( $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
array( [
'disc', 'disc',
'circle', 'circle',
'square', 'square',
@ -87,7 +87,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'lower-alpha', 'lower-alpha',
'upper-alpha', 'upper-alpha',
'none' 'none'
), ],
false false
); );
$this->info['list-style-image'] = $uri_or_none; $this->info['list-style-image'] = $uri_or_none;
@ -95,34 +95,34 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config);
$this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
array('capitalize', 'uppercase', 'lowercase', 'none'), ['capitalize', 'uppercase', 'lowercase', 'none'],
false false
); );
$this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color();
$this->info['background-image'] = $uri_or_none; $this->info['background-image'] = $uri_or_none;
$this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum(
array('repeat', 'repeat-x', 'repeat-y', 'no-repeat') ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
); );
$this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum( $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum(
array('scroll', 'fixed') ['scroll', 'fixed']
); );
$this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
$this->info['background-size'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['background-size'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum( new HTMLPurifier_AttrDef_Enum(
array( [
'auto', 'auto',
'cover', 'cover',
'contain', 'contain',
'initial', 'initial',
'inherit', 'inherit',
) ]
), ),
new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_CSS_Percentage(),
new HTMLPurifier_AttrDef_CSS_Length() new HTMLPurifier_AttrDef_CSS_Length()
) ]
); );
$border_color = $border_color =
@ -131,10 +131,10 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['border-left-color'] = $this->info['border-left-color'] =
$this->info['border-right-color'] = $this->info['border-right-color'] =
$this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('transparent')), new HTMLPurifier_AttrDef_Enum(['transparent']),
new HTMLPurifier_AttrDef_CSS_Color() new HTMLPurifier_AttrDef_CSS_Color()
) ]
); );
$this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config);
@ -146,32 +146,32 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['border-bottom-width'] = $this->info['border-bottom-width'] =
$this->info['border-left-width'] = $this->info['border-left-width'] =
$this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')), new HTMLPurifier_AttrDef_Enum(['thin', 'medium', 'thick']),
new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative
) ]
); );
$this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width);
$this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_Enum(['normal']),
new HTMLPurifier_AttrDef_CSS_Length() new HTMLPurifier_AttrDef_CSS_Length()
) ]
); );
$this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_Enum(['normal']),
new HTMLPurifier_AttrDef_CSS_Length() new HTMLPurifier_AttrDef_CSS_Length()
) ]
); );
$this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum( new HTMLPurifier_AttrDef_Enum(
array( [
'xx-small', 'xx-small',
'x-small', 'x-small',
'small', 'small',
@ -181,20 +181,20 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'xx-large', 'xx-large',
'larger', 'larger',
'smaller' 'smaller'
) ]
), ),
new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_CSS_Percentage(),
new HTMLPurifier_AttrDef_CSS_Length() new HTMLPurifier_AttrDef_CSS_Length()
) ]
); );
$this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_Enum(['normal']),
new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives
new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true) new HTMLPurifier_AttrDef_CSS_Percentage(true)
) ]
); );
$margin = $margin =
@ -202,11 +202,11 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['margin-bottom'] = $this->info['margin-bottom'] =
$this->info['margin-left'] = $this->info['margin-left'] =
$this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Length(),
new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_CSS_Percentage(),
new HTMLPurifier_AttrDef_Enum(array('auto')) new HTMLPurifier_AttrDef_Enum(['auto'])
) ]
); );
$this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin);
@ -217,41 +217,41 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['padding-bottom'] = $this->info['padding-bottom'] =
$this->info['padding-left'] = $this->info['padding-left'] =
$this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true) new HTMLPurifier_AttrDef_CSS_Percentage(true)
) ]
); );
$this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding);
$this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Length(),
new HTMLPurifier_AttrDef_CSS_Percentage() new HTMLPurifier_AttrDef_CSS_Percentage()
) ]
); );
$trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite( $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_CSS_Percentage(true),
new HTMLPurifier_AttrDef_Enum(array('auto', 'initial', 'inherit')) new HTMLPurifier_AttrDef_Enum(['auto', 'initial', 'inherit'])
) ]
); );
$trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite( $trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_CSS_Percentage(true),
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit')) new HTMLPurifier_AttrDef_Enum(['initial', 'inherit'])
) ]
); );
$trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite( $trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_CSS_Percentage(true),
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit')) new HTMLPurifier_AttrDef_Enum(['none', 'initial', 'inherit'])
) ]
); );
$max = $config->get('CSS.MaxImgLength'); $max = $config->get('CSS.MaxImgLength');
@ -263,10 +263,10 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'img', 'img',
// For img tags: // For img tags:
new HTMLPurifier_AttrDef_CSS_Composite( new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0', $max), new HTMLPurifier_AttrDef_CSS_Length('0', $max),
new HTMLPurifier_AttrDef_Enum(array('auto')) new HTMLPurifier_AttrDef_Enum(['auto'])
) ]
), ),
// For everyone else: // For everyone else:
$trusted_wh $trusted_wh
@ -279,10 +279,10 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'img', 'img',
// For img tags: // For img tags:
new HTMLPurifier_AttrDef_CSS_Composite( new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0', $max), new HTMLPurifier_AttrDef_CSS_Length('0', $max),
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit')) new HTMLPurifier_AttrDef_Enum(['initial', 'inherit'])
) ]
), ),
// For everyone else: // For everyone else:
$trusted_min_wh $trusted_min_wh
@ -295,22 +295,39 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'img', 'img',
// For img tags: // For img tags:
new HTMLPurifier_AttrDef_CSS_Composite( new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length('0', $max), new HTMLPurifier_AttrDef_CSS_Length('0', $max),
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit')) new HTMLPurifier_AttrDef_Enum(['none', 'initial', 'inherit'])
) ]
), ),
// For everyone else: // For everyone else:
$trusted_max_wh $trusted_max_wh
); );
// text-decoration and related shorthands
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration();
$this->info['text-decoration-line'] = new HTMLPurifier_AttrDef_Enum(
['none', 'underline', 'overline', 'line-through', 'initial', 'inherit']
);
$this->info['text-decoration-style'] = new HTMLPurifier_AttrDef_Enum(
['solid', 'double', 'dotted', 'dashed', 'wavy', 'initial', 'inherit']
);
$this->info['text-decoration-color'] = new HTMLPurifier_AttrDef_CSS_Color();
$this->info['text-decoration-thickness'] = new HTMLPurifier_AttrDef_CSS_Composite([
new HTMLPurifier_AttrDef_CSS_Length(),
new HTMLPurifier_AttrDef_CSS_Percentage(),
new HTMLPurifier_AttrDef_Enum(['auto', 'from-font', 'initial', 'inherit'])
]);
$this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily();
// this could use specialized code // this could use specialized code
$this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
array( [
'normal', 'normal',
'bold', 'bold',
'bolder', 'bolder',
@ -324,7 +341,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'700', '700',
'800', '800',
'900' '900'
), ],
false false
); );
@ -340,21 +357,21 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
$this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config);
$this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum( $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(
array('collapse', 'separate') ['collapse', 'separate']
); );
$this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum( $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum(
array('top', 'bottom') ['top', 'bottom']
); );
$this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum( $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(
array('auto', 'fixed') ['auto', 'fixed']
); );
$this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Enum( new HTMLPurifier_AttrDef_Enum(
array( [
'baseline', 'baseline',
'sub', 'sub',
'super', 'super',
@ -363,11 +380,11 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'middle', 'middle',
'bottom', 'bottom',
'text-bottom' 'text-bottom'
) ]
), ),
new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Length(),
new HTMLPurifier_AttrDef_CSS_Percentage() new HTMLPurifier_AttrDef_CSS_Percentage()
) ]
); );
$this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2); $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2);
@ -375,7 +392,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
// These CSS properties don't work on many browsers, but we live // These CSS properties don't work on many browsers, but we live
// in THE FUTURE! // in THE FUTURE!
$this->info['white-space'] = new HTMLPurifier_AttrDef_Enum( $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(
array('nowrap', 'normal', 'pre', 'pre-wrap', 'pre-line') ['nowrap', 'normal', 'pre', 'pre-wrap', 'pre-line']
); );
if ($config->get('CSS.Proprietary')) { if ($config->get('CSS.Proprietary')) {
@ -422,21 +439,21 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
// more CSS3 // more CSS3
$this->info['page-break-after'] = $this->info['page-break-after'] =
$this->info['page-break-before'] = new HTMLPurifier_AttrDef_Enum( $this->info['page-break-before'] = new HTMLPurifier_AttrDef_Enum(
array( [
'auto', 'auto',
'always', 'always',
'avoid', 'avoid',
'left', 'left',
'right' 'right'
) ]
); );
$this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(array('auto', 'avoid')); $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(['auto', 'avoid']);
$border_radius = new HTMLPurifier_AttrDef_CSS_Composite( $border_radius = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative
new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative
)); ]);
$this->info['border-top-left-radius'] = $this->info['border-top-left-radius'] =
$this->info['border-top-right-radius'] = $this->info['border-top-right-radius'] =
@ -453,7 +470,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
protected function doSetupTricky($config) protected function doSetupTricky($config)
{ {
$this->info['display'] = new HTMLPurifier_AttrDef_Enum( $this->info['display'] = new HTMLPurifier_AttrDef_Enum(
array( [
'inline', 'inline',
'block', 'block',
'list-item', 'list-item',
@ -472,12 +489,12 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
'table-cell', 'table-cell',
'table-caption', 'table-caption',
'none' 'none'
) ]
); );
$this->info['visibility'] = new HTMLPurifier_AttrDef_Enum( $this->info['visibility'] = new HTMLPurifier_AttrDef_Enum(
array('visible', 'hidden', 'collapse') ['visible', 'hidden', 'collapse']
); );
$this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(array('visible', 'hidden', 'auto', 'scroll')); $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(['visible', 'hidden', 'auto', 'scroll']);
$this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue();
} }
@ -487,23 +504,23 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
protected function doSetupTrusted($config) protected function doSetupTrusted($config)
{ {
$this->info['position'] = new HTMLPurifier_AttrDef_Enum( $this->info['position'] = new HTMLPurifier_AttrDef_Enum(
array('static', 'relative', 'absolute', 'fixed') ['static', 'relative', 'absolute', 'fixed']
); );
$this->info['top'] = $this->info['top'] =
$this->info['left'] = $this->info['left'] =
$this->info['right'] = $this->info['right'] =
$this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Length(),
new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_CSS_Percentage(),
new HTMLPurifier_AttrDef_Enum(array('auto')), new HTMLPurifier_AttrDef_Enum(['auto']),
) ]
); );
$this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite( $this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite(
array( [
new HTMLPurifier_AttrDef_Integer(), new HTMLPurifier_AttrDef_Integer(),
new HTMLPurifier_AttrDef_Enum(array('auto')), new HTMLPurifier_AttrDef_Enum(['auto']),
) ]
); );
} }

View File

@ -73,6 +73,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('min-width:50vw;'); $this->assertDef('min-width:50vw;');
$this->assertDef('min-width:-50vw;', false); $this->assertDef('min-width:-50vw;', false);
$this->assertDef('text-decoration:underline;'); $this->assertDef('text-decoration:underline;');
$this->assertDef('text-decoration-line:overline;');
$this->assertDef('text-decoration-style:dashed;');
$this->assertDef('text-decoration-color:#F00;');
$this->assertDef('text-decoration-thickness:5%;');
$this->assertDef('font-family:sans-serif;'); $this->assertDef('font-family:sans-serif;');
$this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;"); $this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;");
$this->assertDef('font:12px serif;'); $this->assertDef('font:12px serif;');