Fux #2006 allow some aspect-ratio values and all valid object-fit values in HTML filter

This commit is contained in:
Kijin Sung 2022-10-29 21:23:39 +09:00
parent bf54cd8ceb
commit a44959382e
2 changed files with 16 additions and 0 deletions

View file

@ -441,6 +441,14 @@ class HTMLFilter
$info['resize'] = new \HTMLPurifier_AttrDef_Enum(array(
'none', 'both', 'horizontal', 'vertical', 'initial', 'inherit',
));
$info['aspect-ratio'] = new \HTMLPurifier_AttrDef_CSS_Composite(array(
new \HTMLPurifier_AttrDef_CSS_Number(),
new \HTMLPurifier_AttrDef_Enum(array('2/1', '16/9', '4/3', '1/1', '3/4', '9/16', '1/2')),
new \HTMLPurifier_AttrDef_Enum(array('auto', 'initial', 'inherit')),
));
$info['object-fit'] = new \HTMLPurifier_AttrDef_Enum(array(
'contain', 'cover', 'fill', 'none', 'scale-down', 'initial', 'inherit',
));
// Wrap all new properties with a decorator that handles !important.
$allow_important = $config->get('CSS.AllowImportant');

View file

@ -98,6 +98,14 @@ class HTMLFilterTest extends \Codeception\TestCase\Test
$source = '<div style="overflow-x:auto;overflow-y:scroll;left:-500px;"></div>';
$target = '<div style="overflow-x:auto;overflow-y:scroll;"></div>';
$this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source));
$source = '<div style="aspect-ratio:9/16;object-fit:cover;"></div>';
$target = '<div style="aspect-ratio:9/16;object-fit:cover;"></div>';
$this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source));
$source = '<div style="aspect-ratio:3;"></div>';
$target = '<div style="aspect-ratio:3;"></div>';
$this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source));
}
public function testHTMLFilterEmbeddedMedia()