From bc78f0ad2711bc87609acbda927a1cc38ca49516 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 16 Jul 2020 12:41:49 -0700 Subject: [PATCH] gtimezone: support POSIX 1003.1-2001 quoted TZ abbreviations TZ strings like '<-03>3' were introduced in POSIX 1003.1-2001 and are currently specified in: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 --- glib/gtimezone.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/glib/gtimezone.c b/glib/gtimezone.c index 358b52aa4..296af3dd0 100644 --- a/glib/gtimezone.c +++ b/glib/gtimezone.c @@ -1366,14 +1366,24 @@ parse_identifier_boundary (gchar **pos, TimeZoneDate *target) static gboolean set_tz_name (gchar **pos, gchar *buffer, guint size) { + gboolean quoted = **pos == '<'; gchar *name_pos = *pos; guint len; - /* Name is ASCII alpha (Is this necessarily true?) */ - while (g_ascii_isalpha (**pos)) - ++(*pos); + if (quoted) + { + name_pos++; + do + ++(*pos); + while (g_ascii_isalnum (**pos) || **pos == '-' || **pos == '+'); + if (**pos != '>') + return FALSE; + } + else + while (g_ascii_isalpha (**pos)) + ++(*pos); - /* Name should be three or more alphabetic characters */ + /* Name should be three or more characters */ if (*pos - name_pos < 3) return FALSE; @@ -1381,6 +1391,7 @@ set_tz_name (gchar **pos, gchar *buffer, guint size) /* name_pos isn't 0-terminated, so we have to limit the length expressly */ len = *pos - name_pos > size - 1 ? size - 1 : *pos - name_pos; strncpy (buffer, name_pos, len); + *pos += quoted; return TRUE; }