diff --git a/tine20/Tinebase/Convert/VCalendar/Abstract.php b/tine20/Tinebase/Convert/VCalendar/Abstract.php index f1e9839122..7ed1c9ca38 100644 --- a/tine20/Tinebase/Convert/VCalendar/Abstract.php +++ b/tine20/Tinebase/Convert/VCalendar/Abstract.php @@ -57,18 +57,19 @@ public static function getVObject($blob) $blob = stream_get_contents($blob); } - $blob = Tinebase_Core::filterInputForDatabase($blob); + $filteredBlob = Tinebase_Core::filterInputForDatabase($blob); try { - $vcalendar = self::readVCalBlob($blob); + $vcalendar = self::readVCalBlob($filteredBlob); } catch (Sabre\VObject\ParseException $svpe) { - // try again with utf8_encoded blob - $utf8_blob = Tinebase_Helper::mbConvertTo($blob); - // alse replace some linebreaks and \x00's + // replace some linebreaks and \x00's $search = array("\r\n", "\x00"); $replace = array("\n", ''); - $utf8_blob = str_replace($search, $replace, $utf8_blob); - $vcalendar = self::readVCalBlob($utf8_blob); + $filteredBlob = str_replace($search, $replace, $blob); + // try again with utf8_encoded blob + $filteredBlob = Tinebase_Helper::mbConvertTo($filteredBlob); + + $vcalendar = self::readVCalBlob($filteredBlob); } return $vcalendar; diff --git a/tine20/Tinebase/Helper.php b/tine20/Tinebase/Helper.php index 9e2591e9f3..e5574f1919 100644 --- a/tine20/Tinebase/Helper.php +++ b/tine20/Tinebase/Helper.php @@ -261,12 +261,12 @@ public static function in_array_case($_arr, $_str) * @param string $encodingTo (default: utf-8) * @return string */ - public static function mbConvertTo($string, $encodingTo = 'utf-8') + public static function mbConvertTo($string, $encodingTo = 'UTF-8') { // try to fix bad encodings $encoding = mb_detect_encoding((string)$string, 'UTF-8', true); if ($encoding !== 'UTF-8') { - $encoding = mb_detect_encoding((string)$string, array('UTF-8', 'iso-8859-1', 'iso-8859-15')); + $encoding = mb_detect_encoding((string)$string, array('UTF-8', 'ISO-8859-1', 'ISO-8859-15')); } if ($encoding !== FALSE) { $string = @mb_convert_encoding((string)$string, $encodingTo, $encoding);