]> granicus.if.org Git - icu/commitdiff
ICU-21429 Allow timezones with max 2 digits at the end to
authorBernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Thu, 19 Aug 2021 10:41:02 +0000 (12:41 +0200)
committerYoshito Umaoka <yumaoka@users.noreply.github.com>
Fri, 17 Sep 2021 19:26:06 +0000 (15:26 -0400)
icu4c/source/common/putil.cpp

index 638a28e517c41560a86a83c4605a181ac810b1c3..68be079b3a3c0eff4643de9051de1297c50379dd 100644 (file)
@@ -727,8 +727,10 @@ static char *gTimeZoneBufferPtr = NULL;
 
 #if !U_PLATFORM_USES_ONLY_WIN32_API
 #define isNonDigit(ch) (ch < '0' || '9' < ch)
+#define isDigit(ch) ('0' <= ch && ch <= '9')
 static UBool isValidOlsonID(const char *id) {
     int32_t idx = 0;
+    int32_t idxMax = 0;
 
     /* Determine if this is something like Iceland (Olson ID)
     or AST4ADT (non-Olson ID) */
@@ -736,6 +738,13 @@ static UBool isValidOlsonID(const char *id) {
         idx++;
     }
 
+    /* Allow at maximum 2 numbers at the end of the id to support zone id's
+    like GMT+11. */
+    idxMax = idx + 2;
+    while (id[idx] && isDigit(id[idx]) && idx < idxMax) {
+        idx++;
+    }
+
     /* If we went through the whole string, then it might be okay.
     The timezone is sometimes set to "CST-7CDT", "CST6CDT5,J129,J131/19:30",
     "GRNLNDST3GRNLNDDT" or similar, so we cannot use it.