From 44baee6a82b3fcc5ae6b28e07e0d2b1f9f551681 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 30 Jun 2016 22:22:13 -0400 Subject: [PATCH] Partial border-radius support. Signed-off-by: Edward Z. Yang --- NEWS | 3 +++ configdoc/usage.xml | 4 ++-- library/HTMLPurifier/CSSDefinition.php | 13 +++++++++++++ tests/HTMLPurifier/AttrDef/CSSTest.php | 2 ++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 576365ed..7fdc3e0a 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier ! Full PHP 7 compatibility, the test suite is ALL GO. ! %CSS.AllowDuplicates permits duplicate CSS properties. ! Support for 'tel' URIs. +! Partial support for 'border-radius' properties when %CSS.AllowProprietary is true. + The slash syntax, i.e., 'border-radius: 2em 1em 4em / 0.5em 3em' is not + yet supported. - alt truncation could result in malformed UTF-8 sequence. Don't truncate. Thanks Brandon Farber for reporting. - Linkify regex is smarter, based off of Gruber's regex. diff --git a/configdoc/usage.xml b/configdoc/usage.xml index d3856974..b4d0d863 100644 --- a/configdoc/usage.xml +++ b/configdoc/usage.xml @@ -44,12 +44,12 @@ - 447 + 460 - 463 + 476 diff --git a/library/HTMLPurifier/CSSDefinition.php b/library/HTMLPurifier/CSSDefinition.php index 07cc9417..a99172d4 100644 --- a/library/HTMLPurifier/CSSDefinition.php +++ b/library/HTMLPurifier/CSSDefinition.php @@ -370,6 +370,19 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition ); $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(array('auto', 'avoid')); + $border_radius = new HTMLPurifier_AttrDef_CSS_Composite( + array( + new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative + new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative + )); + + $this->info['border-top-left-radius'] = + $this->info['border-top-right-radius'] = + $this->info['border-bottom-right-radius'] = + $this->info['border-bottom-left-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 2); + // TODO: support SLASH syntax + $this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 4); + } /** diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index 46779154..da2ab6b0 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -133,6 +133,8 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness $this->assertDef('-khtml-opacity:.2;'); $this->assertDef('filter:alpha(opacity=20);'); + $this->assertDef('border-top-left-radius:55pt 25pt;'); + } public function testImportant() -- 2.11.4.GIT