From: Yehuda Sadeh Date: Tue, 31 Jul 2012 23:17:22 +0000 (-0700) Subject: rgw: expand date format support X-Git-Tag: v0.48.1argonaut~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2e77130d5c80220be1612b5499d422de620d2d0b;p=ceph.git rgw: expand date format support Relaxing the date format parsing function to allow UTC instead of GMT. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 9aeb24a1a04..675444b4b84 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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)