Fix poorly written timezone parsing
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 6 Dec 2022 11:42:23 +0000 (11:42 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 6 Dec 2022 11:42:23 +0000 (11:42 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14979 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php

index 7e9f74848be57fa562a59ba18153c3d914e1215c..c22e54f6d6c7c4dcc7df6318f817663a2aafa698 100644 (file)
@@ -83,13 +83,16 @@ function getGMTSeconds($stamp, $tzc) {
             break;
     }
     $neg = false;
-    if (substr($tzc, 0, 1) == '-') {
-        $neg = true;
-    } else if (substr($tzc, 0, 1) != '+') {
-        $tzc = '+'.$tzc;
+    if (preg_match('/^([+-]?)(\d\d)(\d\d)$/', $tzc, $matches)) {
+        if ($matches[1] === '-')
+            $neg = true;
+        $hh = $matches[2];
+        $mm = $matches[3];
+    } else {
+        // anything not listed above and not in the form +0400
+        // defaults to UTC
+        $hh = $mm = 0;
     }
-    $hh = substr($tzc,1,2);
-    $mm = substr($tzc,3,2);
     $iTzc = ($hh * 60 + $mm) * 60;
     if ($neg) $iTzc = -1 * (int) $iTzc;
     /* stamp in gmt */