[PR][php-src][#1131][master] - Bug #69151 - mb_ereg should reject ill-formed byte sequence
| From: | noreply@php.net | Date: | Mon, 09 Mar 2015 00:08:27 +0000 |
| Subject: | [PR][php-src][#1131][master] - Bug #69151 - mb_ereg should reject ill-formed byte sequence | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-2666@lists.php.net to get a copy of this message | ||
You can view the Pull Request on github:
https://github.com/php/php-src/pull/1131
Pull Request Description:
This pull request add validation for encoding. Some of ill-formed byte sequence can be converterted
to dangerous ascii characters by legacy UTF-8 decoder without checking trailing bytes.
htmlspecharchars and PCRE functions reject them. [Unicode Security
Guide](http://websec.github.io/unicode-security-guide/character-transformations/#handling) shows
example. "C2 22 3C" can be treated as "C2 22" + "3C". "3C"
means "<".
```php
// http://websec.github.io/unicode-security-guide/character-transformations/#handling
//
// Code point First byte Second byte Third byte Fourth byte
// U+0000..U+007F 00..7F
// U+0080..U+07FF C2..DF 80..BF
// U+0800..U+0FFF E0 A0..BF 80..BF
$str = "\xC2\x22\x3C";
var_dump(
"" === htmlspecialchars($str),
false === preg_match('/./u', $str)
);
```