From a9c11c473b547b17f5366aa7b7514d32cf34a873 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Thu, 17 May 2018 12:18:27 +0200 Subject: [PATCH] CSSMin: Do not escape U+FFFD as code point The current editors draft from 23 April 2018 does not require to escape the REPLACEMENT CHARACTER (U+FFFD) as code point anymore. https://drafts.csswg.org/cssom/#serialize-a-string If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD). https://www.w3.org/TR/2016/WD-cssom-1-20160317/#serialize-a-string If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD) escaped as code point. Change-Id: Ia67e89b3c9561ca29e133d61a2eca8f3db306d8c --- includes/libs/CSSMin.php | 4 ++-- tests/phpunit/includes/libs/CSSMinTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index a6014b1ecd..c2272688e9 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -173,13 +173,13 @@ class CSSMin { /** * Serialize a string (escape and quote) for use as a CSS string value. - * https://www.w3.org/TR/2016/WD-cssom-1-20160317/#serialize-a-string + * https://drafts.csswg.org/cssom/#serialize-a-string * * @param string $value * @return string */ public static function serializeStringValue( $value ) { - $value = strtr( $value, [ "\0" => "\\fffd ", '\\' => '\\\\', '"' => '\\"' ] ); + $value = strtr( $value, [ "\0" => "\xEF\xBF\xBD", '\\' => '\\\\', '"' => '\\"' ] ); $value = preg_replace_callback( '/[\x01-\x1f\x7f]/', function ( $match ) { return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' '; }, $value ); diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index dabf66b320..3876a68b8d 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -35,7 +35,7 @@ class CSSMinTest extends MediaWikiTestCase { public static function provideSerializeStringValue() { return [ [ 'Hello World!', '"Hello World!"' ], - [ "Null\0Null", "\"Null\\fffd Null\"" ], + [ "Null\0Null", "\"Null\xEF\xBF\xBDNull\"" ], [ '"', '"\\""' ], [ "'", '"\'"' ], [ "\\", '"\\\\"' ], -- 2.20.1