From f1c07977809ce3221286d53e99f0d91145b1166f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 25 Apr 2019 11:24:09 +0200 Subject: Revert "update composer libs" This reverts commit e779335d060b3a51d6a144d23af4097ae6801473 --- vendor/sabre/vobject/lib/StringUtil.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'vendor/sabre/vobject/lib/StringUtil.php') diff --git a/vendor/sabre/vobject/lib/StringUtil.php b/vendor/sabre/vobject/lib/StringUtil.php index 2333d6ab9..b8615f2ba 100644 --- a/vendor/sabre/vobject/lib/StringUtil.php +++ b/vendor/sabre/vobject/lib/StringUtil.php @@ -9,8 +9,8 @@ namespace Sabre\VObject; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil -{ +class StringUtil { + /** * Returns true or false depending on if a string is valid UTF-8. * @@ -18,14 +18,15 @@ class StringUtil * * @return bool */ - public static function isUTF8($str) - { + static function isUTF8($str) { + // Control characters if (preg_match('%[\x00-\x08\x0B-\x0C\x0E\x0F]%', $str)) { return false; } - return (bool) preg_match('%%u', $str); + return (bool)preg_match('%%u', $str); + } /** @@ -38,12 +39,12 @@ class StringUtil * * @return string */ - public static function convertToUTF8($str) - { + static function convertToUTF8($str) { + $encoding = mb_detect_encoding($str, ['UTF-8', 'ISO-8859-1', 'WINDOWS-1252'], true); switch ($encoding) { - case 'ISO-8859-1': + case 'ISO-8859-1' : $newStr = utf8_encode($str); break; /* Unreachable code. Not sure yet how we can improve this @@ -52,11 +53,14 @@ class StringUtil $newStr = iconv('cp1252', 'UTF-8', $str); break; */ - default: + default : $newStr = $str; + } // Removing any control characters - return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr); + return (preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr)); + } + } -- cgit v1.2.3