Skip to content

Commit

Permalink
Merge pull request #9 from nguyenanhung/v2.x
Browse files Browse the repository at this point in the history
Update Project at Tue Aug  8 13:20:48 +07 2023
  • Loading branch information
nguyenanhung authored Aug 8, 2023
2 parents b993148 + 54a4d71 commit 98e7933
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function getRandomBytes(int $length)
*/
public function entityDecode(string $str, string $charset = null): string
{
if (strpos($str, '&') === false) {
if (mb_strpos($str, '&') === false) {
return $str;
}

Expand Down Expand Up @@ -281,7 +281,7 @@ public function entityDecode(string $str, string $charset = null): string
*/
public function doHash(string $str, string $type = 'sha1'): string
{
if (!in_array(strtolower($type), hash_algos(), true)) {
if (!in_array(mb_strtolower($type), hash_algos(), true)) {
$type = 'md5';
}

Expand Down Expand Up @@ -571,7 +571,7 @@ public function xssClean($str, bool $isImage = false)
*
* Note: Use rawurldecode() so it does not remove plus signs
*/
if (strpos($str, '%') !== false) {
if (mb_strpos($str, '%') !== false) {
do {
$oldStr = $str;
$str = rawurldecode($str);
Expand Down Expand Up @@ -641,7 +641,7 @@ public function xssClean($str, bool $isImage = false)

// We only want to do this when it is followed by a non-word character
// That way valid stuff like "dealer to" does not become "dealerto"
$str = preg_replace_callback('#(' . substr($word, 0, -3) . ')(\W)#is', array($this, '_compactExplodedWords'), $str);
$str = preg_replace_callback('#(' . mb_substr($word, 0, -3) . ')(\W)#is', array($this, '_compactExplodedWords'), $str);
}

/*
Expand Down Expand Up @@ -884,7 +884,7 @@ protected function _sanitizeNaughtyHtml($matches): string
return '<' . $matches[1];
}

if (in_array(strtolower($matches['tagName']), $naughty_tags, true)) {
if (in_array(mb_strtolower($matches['tagName']), $naughty_tags, true)) {
return '<' . $matches[1] . '>';
}

Expand Down Expand Up @@ -921,7 +921,7 @@ protected function _sanitizeNaughtyHtml($matches): string
$attributes[] = $attribute[0][0];
}

$matches['attributes'] = substr($matches['attributes'], $attribute[0][1] + strlen($attribute[0][0]));
$matches['attributes'] = mb_substr($matches['attributes'], $attribute[0][1] + mb_strlen($attribute[0][0]));
}
while ($matches['attributes'] !== '');

Expand Down

0 comments on commit 98e7933

Please sign in to comment.