CSSMin::serializeStringValue: Update implementation to new specification
authorFomafix <fomafix@googlemail.com>
Wed, 11 Apr 2018 04:23:50 +0000 (06:23 +0200)
committerFomafix <fomafix@googlemail.com>
Fri, 13 Apr 2018 03:58:25 +0000 (05:58 +0200)
commitd37c017994d2771b41209f571874b096c77e785d
tree925fd7bbd98a01c0be6d40194a4a3df093797f88
parentbf56ea38746c35ca1b5daa23c3e92bb7e86b6b19
CSSMin::serializeStringValue: Update implementation to new specification

The current version of https://www.w3.org/TR/cssom/ is
https://www.w3.org/TR/2016/WD-cssom-1-20160317/

The new specification for CSS string serialization
https://www.w3.org/TR/2016/WD-cssom-1-20160317/#serialize-a-string
has some changes compared to the old specification
https://www.w3.org/TR/2013/WD-cssom-20131205/#serialize-a-string
* U+0000 get replaced by the REPLACEMENT CHARACTER (U+FFFD) instead of
  throwing an exception.
* U+0080 to U+009F are not escaped.

The old implementation has a bug because it selects the byte range
[\x7f-\x9f] and not unicode codepoint range [\u007f-\u009f]. This
breaks the encoding because CSS is in UTF-8 not in ISO 8859-x.

Also add tests to cover CSSMin::serializeStringValue.

Bug: T192048
Change-Id: I894824c216b95dbba461308488fba33121ffea54
includes/libs/CSSMin.php
tests/phpunit/includes/libs/CSSMinTest.php