]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: expand date format support
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 31 Jul 2012 23:17:22 +0000 (16:17 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 10 Aug 2012 17:39:47 +0000 (10:39 -0700)
Relaxing the date format parsing function to allow UTC
instead of GMT.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_common.cc

index 9aeb24a1a04b189f8f2d86c341e8322243ac7d14..675444b4b84b34c82f9b5e8c46ae9043a80d7aee 100644 (file)
@@ -136,10 +136,36 @@ static bool check_str_end(const char *s)
   return true;
 }
 
+static bool check_gmt_end(const char *s)
+{
+  if (!s || !*s)
+    return false;
+
+  while (isspace(*s)) {
+    ++s;
+  }
+
+  /* check for correct timezone */
+  if ((strncmp(s, "GMT", 3) != 0) &&
+      (strncmp(s, "UTC", 3) != 0)) {
+    return false;
+  }
+
+  /* trailing space */
+  s += 3;
+  while (isspace(*s)) {
+    ++s;
+  }
+  if (*s)
+    return false;
+
+  return true;
+}
+
 static bool parse_rfc850(const char *s, struct tm *t)
 {
   memset(t, 0, sizeof(*t));
-  return check_str_end(strptime(s, "%A, %d-%b-%y %H:%M:%S GMT", t));
+  return check_gmt_end(strptime(s, "%A, %d-%b-%y %H:%M:%S ", t));
 }
 
 static bool parse_asctime(const char *s, struct tm *t)
@@ -151,7 +177,7 @@ static bool parse_asctime(const char *s, struct tm *t)
 static bool parse_rfc1123(const char *s, struct tm *t)
 {
   memset(t, 0, sizeof(*t));
-  return check_str_end(strptime(s, "%a, %d %b %Y %H:%M:%S GMT", t));
+  return check_gmt_end(strptime(s, "%a, %d %b %Y %H:%M:%S ", t));
 }
 
 static bool parse_rfc1123_alt(const char *s, struct tm *t)