Adapt StringUtils::isUtf8 to the top of Unicode at U+10FFFF
authorKevin Israel <pleasestand@live.com>
Mon, 16 Sep 2013 03:29:04 +0000 (23:29 -0400)
committerKevin Israel <pleasestand@live.com>
Wed, 18 Sep 2013 21:23:15 +0000 (17:23 -0400)
commit7447669e83910865a061bbae34dad861bf3396d9
tree9a671c3a2053d37b1ad4732394ba063351f9c4ad
parent560742268e7f4eca96fd175a5edb435a53115822
Adapt StringUtils::isUtf8 to the top of Unicode at U+10FFFF

RFC 3629 defines the legal range of characters as U+0000..U+10FFFF
and forbids overlong forms (encodings of a character that use more
bytes than necessary). Let's make StringUtils::isUtf8() match the
specification.

* Changed the maximum value in the pure PHP code path and added a
  check for overlong forms.
* Added another check, specific to PHP 5.3's mbstring extension,
  for values above U+10FFFF.
* Fixed the mbstring test errors in PHP 5.4 using changes to
  StringUtilsTest by Platonides <platonides@gmail.com>.
* Uncommented some other tests that could fail because of the
  missing check for overlong forms.
* Added additional tests for extra continuation bytes, overlong
  sequences/forms, and values in the UTF-16 surrogate range.

The changes to the function were so extensive that I might as
well say I rewrote it.

Bug: 43679
Change-Id: I56ae496d17ffc3747550e06a72dacab3ac55da61
includes/StringUtils.php
tests/phpunit/includes/StringUtilsTest.php