mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
CSS: added "initial" and "inherit" to width + height (#144)
* CSS: added "initial" and "inherit" to width + height CSS: added "initial" and "inherit" to min-width + min-height, removed "auto" CSS: added "initial" and "inherit" and "none" to max-width + max-height, removed "auto" * Fixed test: min-width:auto; should be false
This commit is contained in:
parent
8c153eef3a
commit
7cfc44654a
@ -220,15 +220,25 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
||||
new HTMLPurifier_AttrDef_Enum(array('auto', 'initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
||||
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
||||
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit'))
|
||||
)
|
||||
);
|
||||
$max = $config->get('CSS.MaxImgLength');
|
||||
|
||||
$this->info['min-width'] =
|
||||
$this->info['max-width'] =
|
||||
$this->info['min-height'] =
|
||||
$this->info['max-height'] =
|
||||
$this->info['width'] =
|
||||
$this->info['height'] =
|
||||
$max === null ?
|
||||
@ -245,6 +255,38 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
||||
// For everyone else:
|
||||
$trusted_wh
|
||||
);
|
||||
$this->info['min-width'] =
|
||||
$this->info['min-height'] =
|
||||
$max === null ?
|
||||
$trusted_min_wh :
|
||||
new HTMLPurifier_AttrDef_Switch(
|
||||
'img',
|
||||
// For img tags:
|
||||
new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0', $max),
|
||||
new HTMLPurifier_AttrDef_Enum(array('initial', 'inherit'))
|
||||
)
|
||||
),
|
||||
// For everyone else:
|
||||
$trusted_min_wh
|
||||
);
|
||||
$this->info['max-width'] =
|
||||
$this->info['max-height'] =
|
||||
$max === null ?
|
||||
$trusted_max_wh :
|
||||
new HTMLPurifier_AttrDef_Switch(
|
||||
'img',
|
||||
// For img tags:
|
||||
new HTMLPurifier_AttrDef_CSS_Composite(
|
||||
array(
|
||||
new HTMLPurifier_AttrDef_CSS_Length('0', $max),
|
||||
new HTMLPurifier_AttrDef_Enum(array('none', 'initial', 'inherit'))
|
||||
)
|
||||
),
|
||||
// For everyone else:
|
||||
$trusted_max_wh
|
||||
);
|
||||
|
||||
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration();
|
||||
|
||||
|
@ -64,7 +64,9 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
|
||||
$this->assertDef('width:-50px;', false);
|
||||
$this->assertDef('min-width:50%;');
|
||||
$this->assertDef('min-width:50px;');
|
||||
$this->assertDef('min-width:auto;');
|
||||
$this->assertDef('min-width:auto;', false);
|
||||
$this->assertDef('min-width:initial;');
|
||||
$this->assertDef('min-width:inherit;');
|
||||
$this->assertDef('min-width:-50px;', false);
|
||||
$this->assertDef('min-width:50ch;');
|
||||
$this->assertDef('min-width:50rem;');
|
||||
|
Loading…
Reference in New Issue
Block a user