diff options
author | Daniel Lange <DLange@git.local> | 2016-03-07 15:53:16 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-03-07 15:53:16 +0100 |
commit | 50569114acdc64e7c7cae1498635d3f821517c30 (patch) | |
tree | 13d6fe76af33134fbfb2286930fb6603047f9299 /calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php | |
parent | c210d30de6c62e7f7867bb32651349ddf455d9e6 (diff) | |
download | roundcube_calendar-50569114acdc64e7c7cae1498635d3f821517c30.tar.gz roundcube_calendar-50569114acdc64e7c7cae1498635d3f821517c30.tar.bz2 roundcube_calendar-50569114acdc64e7c7cae1498635d3f821517c30.zip |
Initial commit of the Faster IT roundcube_calendar plugin distribution
This includes:
* Kolab plugins 3.2.9 (calendar and libcalendaring)
* CalDAV driver 3.2.8
* .htaccess files for at least some security
* SabreDAV updated to 1.8.12 (Jan 2015 release)
* Support for CURLOPT_SSL_* settings to allow self-signed certificates
* Small fixes & improved documentation
Diffstat (limited to 'calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php')
-rw-r--r-- | calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php b/calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php new file mode 100644 index 0000000..1218792 --- /dev/null +++ b/calendar/lib/SabreDAV/vendor/oldsabre/vobject/lib/Sabre/VObject/StringUtil.php @@ -0,0 +1,61 @@ +<?php + +namespace OldSabre\VObject; + +/** + * Useful utilities for working with various strings. + * + * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class StringUtil { + + /** + * Returns true or false depending on if a string is valid UTF-8 + * + * @param string $str + * @return bool + */ + static function isUTF8($str) { + + // First check.. mb_check_encoding + if (!mb_check_encoding($str, 'UTF-8')) { + return false; + } + + // Control characters + if (preg_match('%(?:[\x00-\x08\x0B-\x0C\x0E\x0F])%', $str)) { + return false; + } + + return true; + + } + + /** + * This method tries its best to convert the input string to UTF-8. + * + * Currently only ISO-5991-1 input and UTF-8 input is supported, but this + * may be expanded upon if we receive other examples. + * + * @param string $str + * @return string + */ + static function convertToUTF8($str) { + + $encoding = mb_detect_encoding($str , array('UTF-8','ISO-8859-1'), true); + + if ($encoding === 'ISO-8859-1') { + $newStr = utf8_encode($str); + } else { + $newStr = $str; + } + + // Removing any control characters + return (preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E\x0F])%', '', $newStr)); + + } + +} + |