Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ protected function htmlAttrMatcher($matches)
*/
if ($ord > 255) {
return sprintf('&#x%04X;', $ord);
} else {
return sprintf('&#x%02X;', $ord);
}
return sprintf('&#x%02X;', $ord);
}

/**
Expand All @@ -286,10 +285,9 @@ protected function jsMatcher($matches)
$chr = $matches[0];
if (strlen($chr) == 1) {
return sprintf('\\x%02X', ord($chr));
} else {
$chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8');
return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
}
$chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8');
return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
}

/**
Expand Down Expand Up @@ -389,8 +387,7 @@ protected function convertEncoding($string, $to, $from)

if ($result === false) {
return ''; // return non-fatal blank string on encoding errors from users
} else {
return $result;
}
return $result;
}
}

0 comments on commit b09399b

Please sign in to comment.