compare charset strictly

This commit is contained in:
JhonnyL
2016-01-17 20:03:22 +01:00
parent 24d9266d0f
commit 4f327372bd
+13 -13
View File
@@ -386,7 +386,7 @@ function twig_random(Twig_Environment $env, $values = null)
return '';
}
if (null !== $charset = $env->getCharset()) {
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$values = twig_convert_encoding($values, 'UTF-8', $charset);
}
@@ -394,7 +394,7 @@ function twig_random(Twig_Environment $env, $values = null)
// split at all positions, but not after the start and not before the end
$values = preg_split('/(?<!^)(?!$)/u', $values);
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
foreach ($values as $i => $value) {
$values[$i] = twig_convert_encoding($value, $charset, 'UTF-8');
}
@@ -919,7 +919,7 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false
if (null !== $charset = $env->getCharset()) {
$string = (string) $item;
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$item = twig_convert_encoding($string, 'UTF-8', $charset);
}
@@ -927,7 +927,7 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false
$string = implode('', array_reverse($matches[0]));
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
@@ -1053,7 +1053,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
case 'js':
// escape all non-alphanumeric characters
// into their \xHH or \uHHHH representations
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
@@ -1063,14 +1063,14 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string);
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
case 'css':
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
@@ -1080,14 +1080,14 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string);
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
return $string;
case 'html_attr':
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
@@ -1097,7 +1097,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string);
if ('UTF-8' != $charset) {
if ('UTF-8' !== $charset) {
$string = twig_convert_encoding($string, $charset, 'UTF-8');
}
@@ -1275,7 +1275,7 @@ if (function_exists('mb_get_info')) {
*/
function twig_upper_filter(Twig_Environment $env, $string)
{
if (null !== ($charset = $env->getCharset())) {
if (null !== $charset = $env->getCharset()) {
return mb_strtoupper($string, $charset);
}
@@ -1292,7 +1292,7 @@ if (function_exists('mb_get_info')) {
*/
function twig_lower_filter(Twig_Environment $env, $string)
{
if (null !== ($charset = $env->getCharset())) {
if (null !== $charset = $env->getCharset()) {
return mb_strtolower($string, $charset);
}
@@ -1309,7 +1309,7 @@ if (function_exists('mb_get_info')) {
*/
function twig_title_string_filter(Twig_Environment $env, $string)
{
if (null !== ($charset = $env->getCharset())) {
if (null !== $charset = $env->getCharset()) {
return mb_convert_case($string, MB_CASE_TITLE, $charset);
}