diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-05-08 21:52:33 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-05-22 20:14:34 +0200 |
commit | b9f6e89a271c04741231b64b03fe7fc294723f1d (patch) | |
tree | 2f50d95bbbd60fd9f96493b9077157cf77fbab25 /module/web/http.scm | |
parent | 140496cc00736f61d5c8710207288cd9c7acd975 (diff) | |
download | guile-b9f6e89a271c04741231b64b03fe7fc294723f1d.tar.gz |
http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.
* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
Diffstat (limited to 'module/web/http.scm')
-rw-r--r-- | module/web/http.scm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/module/web/http.scm b/module/web/http.scm index 0bcd9058b..8e95fc755 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -751,6 +751,26 @@ as an ordered alist." (minute (parse-non-negative-integer str 19 21)) (second (parse-non-negative-integer str 22 24))) (make-date 0 second minute hour date month year zone-offset))) + + ;; The next two clauses match dates that have a space instead of + ;; a leading zero for hours, like " 8:49:37". + ((string-match? (substring str 0 space) "aaa, dd aaa dddd d:dd:dd") + (let ((date (parse-non-negative-integer str 5 7)) + (month (parse-month str 8 11)) + (year (parse-non-negative-integer str 12 16)) + (hour (parse-non-negative-integer str 18 19)) + (minute (parse-non-negative-integer str 20 22)) + (second (parse-non-negative-integer str 23 25))) + (make-date 0 second minute hour date month year zone-offset))) + ((string-match? (substring str 0 space) "aaa, d aaa dddd d:dd:dd") + (let ((date (parse-non-negative-integer str 5 6)) + (month (parse-month str 7 10)) + (year (parse-non-negative-integer str 11 15)) + (hour (parse-non-negative-integer str 17 18)) + (minute (parse-non-negative-integer str 19 21)) + (second (parse-non-negative-integer str 22 24))) + (make-date 0 second minute hour date month year zone-offset))) + (else (bad-header 'date str) ; prevent tail call #f))) |