From: Fomafix Date: Thu, 17 May 2018 10:18:27 +0000 (+0200) Subject: CSSMin: Do not escape U+FFFD as code point X-Git-Tag: 1.34.0-rc.0~5409^2 X-Git-Url: http://git.cyclocoop.org/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=a9c11c473b547b17f5366aa7b7514d32cf34a873;p=lhc%2Fweb%2Fwiklou.git 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 --- 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\"" ], [ '"', '"\\""' ], [ "'", '"\'"' ], [ "\\", '"\\\\"' ],