diff options
author | Stefan Giehl <stefan@piwik.org> | 2017-09-26 01:28:40 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-09-26 01:28:40 +0300 |
commit | 9c8980844fbdd101975915597b72765e0ef2c7a2 (patch) | |
tree | de0968973e178de75835cb540444ece81392e0ce /core | |
parent | da6e68b04ff532d125e2c1e38be23814c5b8ecd9 (diff) |
Use mbstring proxy methods (#12104)
* Use mbstring proxy methods
* Avoid using strtolower/strtoupper if mbstring is not available to prevent possible unicode problems
Diffstat (limited to 'core')
-rw-r--r-- | core/Common.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/Common.php b/core/Common.php index f884d9fe2f..7430cc6662 100644 --- a/core/Common.php +++ b/core/Common.php @@ -232,7 +232,27 @@ class Common return mb_strtolower($string, 'UTF-8'); } - return strtolower($string); + // return unchanged string as using `strtolower` might cause unicode problems + return $string; + } + + /** + * Multi-byte strtoupper() - works with UTF-8. + * + * Calls `mb_strtoupper` if available and falls back to `strtoupper` if not. + * + * @param string $string + * @return string + * @api + */ + public static function mb_strtoupper($string) + { + if (function_exists('mb_strtoupper')) { + return mb_strtoupper($string, 'UTF-8'); + } + + // return unchanged string as using `strtoupper` might cause unicode problems + return $string; } /* |