no need to run expensive mb_substr 3 times

This commit is contained in:
Ralf Becker 2011-06-08 10:41:22 +00:00
parent 123b46372b
commit c66928875a

View File

@ -51,8 +51,8 @@ class HTMLPurifier_PercentEncoder
$ret = '';
//error_log(__METHOD__.__LINE__.$string);
for ($i = 0, $c = strlen($string); $i < $c; $i++) {
if (substr($string,$i,1) !== '%' && !isset($this->preserve[$int = ord(substr($string,$i,1))]) ) {
$ret .= rawurlencode(substr($string,$i,1)); // '%' . sprintf('%02X', $int);
if (($chr=substr($string,$i,1)) !== '%' && !isset($this->preserve[$int = ord($chr)])) {
$ret .= rawurlencode($chr); // '%' . sprintf('%02X', $int);
} else {
$ret .= substr($string,$i,1);
}