From 67c3798922342ffc652e629a839de540fedd90d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dagef=C3=B6rde?= Date: Sun, 15 Oct 2017 19:02:38 +0200 Subject: [PATCH] Add relative length units from CSS 3 cf. https://www.w3schools.com/cssref/css_units.asp --- library/HTMLPurifier/Length.php | 6 ++++-- tests/HTMLPurifier/AttrDef/CSSTest.php | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/HTMLPurifier/Length.php b/library/HTMLPurifier/Length.php index bbfbe662..e70da55a 100644 --- a/library/HTMLPurifier/Length.php +++ b/library/HTMLPurifier/Length.php @@ -26,12 +26,14 @@ class HTMLPurifier_Length protected $isValid; /** - * Array Lookup array of units recognized by CSS 2.1 + * Array Lookup array of units recognized by CSS 3 * @type array */ protected static $allowedUnits = array( 'em' => true, 'ex' => true, 'px' => true, 'in' => true, - 'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true + 'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true, + 'ch' => true, 'rem' => true, 'vw' => true, 'vh' => true, + 'vmin' => true, 'vmax' => true ); /** diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index 718b5be6..2d938cec 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -66,6 +66,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness $this->assertDef('min-width:50px;'); $this->assertDef('min-width:auto;'); $this->assertDef('min-width:-50px;', false); + $this->assertDef('min-width:50ch;'); + $this->assertDef('min-width:50rem;'); + $this->assertDef('min-width:50vw;'); + $this->assertDef('min-width:-50vw;', false); $this->assertDef('text-decoration:underline;'); $this->assertDef('font-family:sans-serif;'); $this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;"); -- 2.11.4.GIT