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
/**
* 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 );
public static function provideSerializeStringValue() {
return [
[ 'Hello World!', '"Hello World!"' ],
- [ "Null\0Null", "\"Null\\fffd Null\"" ],
+ [ "Null\0Null", "\"Null\xEF\xBF\xBDNull\"" ],
[ '"', '"\\""' ],
[ "'", '"\'"' ],
[ "\\", '"\\\\"' ],