Don't try to parse dates that start with anything but a digit, a plus or a
authorBastien Nocera <hadess@hadess.net>
Thu, 13 Dec 2007 14:44:37 +0000 (14:44 +0000)
committerBastien Nocera <hadess@src.gnome.org>
Thu, 13 Dec 2007 14:44:37 +0000 (14:44 +0000)
2007-12-13  Bastien Nocera  <hadess@hadess.net>

* glib/gtimer.c: (g_time_val_from_iso8601):
Don't try to parse dates that start with anything but a
digit, a plus or a minus sign, as those can't be valid
ISO8601 dates (Closes: #503029)

svn path=/trunk/; revision=6111

ChangeLog
glib/gtimer.c

index 6ded026..7e75956 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-13  Bastien Nocera  <hadess@hadess.net>
+
+       * glib/gtimer.c: (g_time_val_from_iso8601):
+       Don't try to parse dates that start with anything but a
+       digit, a plus or a minus sign, as those can't be valid
+       ISO8601 dates (Closes: #503029)
+
 2007-12-13  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/gkeyfile.c (g_key_file_clear): Free group_hash.
index aa290d0..3b0b308 100644 (file)
@@ -307,6 +307,16 @@ g_time_val_from_iso8601 (const gchar *iso_date,
   g_return_val_if_fail (iso_date != NULL, FALSE);
   g_return_val_if_fail (time_ != NULL, FALSE);
 
+  /* Ensure that the first character is a digit,
+   * the first digit of the date, otherwise we don't
+   * have an ISO 8601 date */
+  while (g_ascii_isspace (*iso_date))
+    iso_date++;
+  if (*iso_date == '\0')
+    return FALSE;
+  if (!g_ascii_isdigit (*iso_date) || iso_date != '-' || *iso_date != '+')
+    return FALSE;
+
   val = strtoul (iso_date, (char **)&iso_date, 10);
   if (*iso_date == '-')
     {