From c3de1f47eaf841ac7ca14261d048623803f1d321 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 5 Feb 2021 16:27:24 +0100 Subject: [locationinfo] Fix conversion of time zone argument to DateTime Now we properly always convert time zone strings to DateTimeZone instances before passing them to the DateTime(Immutable) constructor as the second argument. The timeZoneStringToDateTimeZone() was made idempotent, to simplify code using it. --- modules-available/locationinfo/inc/icalparser.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules-available/locationinfo/inc/icalparser.inc.php b/modules-available/locationinfo/inc/icalparser.inc.php index 15cd95c6..0be8777b 100644 --- a/modules-available/locationinfo/inc/icalparser.inc.php +++ b/modules-available/locationinfo/inc/icalparser.inc.php @@ -2019,7 +2019,7 @@ class ICalParser foreach (array_keys($subArray) as $key) { if ($key === 'TZID') { - $currentTimeZone = $this->timeZoneStringToDateTimeZone($subArray[$key]); + $currentTimeZone = $subArray[$key]; } elseif (is_numeric($key)) { $icalDate = $subArray[$key]; @@ -2027,7 +2027,7 @@ class ICalParser $currentTimeZone = self::TIME_ZONE_UTC; } - $output[] = new DateTimeImmutable($icalDate, $currentTimeZone); + $output[] = new DateTimeImmutable($icalDate, $this->timeZoneStringToDateTimeZone($currentTimeZone)); if ($key === $finalKey) { // Reset to default @@ -2070,6 +2070,8 @@ class ICalParser */ public function timeZoneStringToDateTimeZone($timeZoneString) { + if ($timeZoneString instanceof DateTimeZone) + return $timeZoneString; // Some time zones contain characters that are not permitted in param-texts, // but are within quoted texts. We need to remove the quotes as they're not // actually part of the time zone. -- cgit v1.2.3-55-g7522