From a44959382efae3d81104d2084d0c2fda9ffc311b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 29 Oct 2022 21:23:39 +0900 Subject: [PATCH] Fux #2006 allow some aspect-ratio values and all valid object-fit values in HTML filter --- common/framework/filters/htmlfilter.php | 8 ++++++++ tests/unit/framework/filters/HTMLFilterTest.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/common/framework/filters/htmlfilter.php b/common/framework/filters/htmlfilter.php index 597463406..cae396c89 100644 --- a/common/framework/filters/htmlfilter.php +++ b/common/framework/filters/htmlfilter.php @@ -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'); diff --git a/tests/unit/framework/filters/HTMLFilterTest.php b/tests/unit/framework/filters/HTMLFilterTest.php index e2db9590e..e894daea8 100644 --- a/tests/unit/framework/filters/HTMLFilterTest.php +++ b/tests/unit/framework/filters/HTMLFilterTest.php @@ -98,6 +98,14 @@ class HTMLFilterTest extends \Codeception\TestCase\Test $source = '
'; $target = '
'; $this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source)); + + $source = '
'; + $target = '
'; + $this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source)); + + $source = '
'; + $target = '
'; + $this->assertEquals($target, Rhymix\Framework\Filters\HTMLFilter::clean($source)); } public function testHTMLFilterEmbeddedMedia()