[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 45/47: http: Accept date strings with a leading space fo
From: |
Andy Wingo |
Subject: |
[Guile-commits] 45/47: http: Accept date strings with a leading space for hours. |
Date: |
Sun, 22 May 2016 18:23:06 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit b9f6e89a271c04741231b64b03fe7fc294723f1d
Author: Ludovic Courtès <address@hidden>
Date: Sun May 8 21:52:33 2016 +0200
http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <address@hidden>.
* 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.
---
module/web/http.scm | 20 ++++++++++++++++++++
test-suite/tests/web-http.test | 10 ++++++++++
2 files changed, 30 insertions(+)
diff --git a/module/web/http.scm b/module/web/http.scm
index 0bcd905..8e95fc7 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)))
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index f88f011..3fda4f9 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -236,6 +236,16 @@
(pass-if-parse date "Wed, 7 Sep 2011 11:25:00 GMT"
(string->date "Wed, 7 Sep 2011 11:25:00 +0000"
"~a,~e ~b ~Y ~H:~M:~S ~z"))
+
+ ;; This is a non-conforming date (lack of leading zero for the hours)
+ ;; that some HTTP servers provide. See <http://bugs.gnu.org/23421>.
+ (pass-if-parse date "Sun, 06 Nov 1994 8:49:37 GMT"
+ (string->date "Sun, 6 Nov 1994 08:49:37 +0000"
+ "~a,~e ~b ~Y ~H:~M:~S ~z"))
+ (pass-if-parse date "Sun, 6 Nov 1994 8:49:37 GMT"
+ (string->date "Sun, 6 Nov 1994 08:49:37 +0000"
+ "~a,~e ~b ~Y ~H:~M:~S ~z"))
+
(pass-if-parse-error date "Tue, 15 Nov 1994 08:12:31 EST" date)
(pass-if-any-error date "Tue, 15 Qux 1994 08:12:31 EST")
- [Guile-commits] 23/47: doc: Fix menu order for SXML., (continued)
- [Guile-commits] 23/47: doc: Fix menu order for SXML., Andy Wingo, 2016/05/22
- [Guile-commits] 30/47: Add new Linux errno constants., Andy Wingo, 2016/05/22
- [Guile-commits] 29/47: Fix the rule to check for new signals and errors, Andy Wingo, 2016/05/22
- [Guile-commits] 35/47: doc: Mention a known-good Flex version number., Andy Wingo, 2016/05/22
- [Guile-commits] 27/47: web: Gracefully handle premature EOF when reading chunk header., Andy Wingo, 2016/05/22
- [Guile-commits] 36/47: build: Add SCM_T_OFF_MAX and SCM_T_OFF_MIN to scmconfig.h., Andy Wingo, 2016/05/22
- [Guile-commits] 22/47: doc: Add SXPath documentation from sources, Andy Wingo, 2016/05/22
- [Guile-commits] 26/47: docs: Fix external representation of <toplevel-define> in tree-il., Andy Wingo, 2016/05/22
- [Guile-commits] 25/47: web: Fix 'close' method of delimited input ports., Andy Wingo, 2016/05/22
- [Guile-commits] 40/47: http: Test that responses lacking CR/LF are rejected., Andy Wingo, 2016/05/22
- [Guile-commits] 45/47: http: Accept date strings with a leading space for hours.,
Andy Wingo <=
- [Guile-commits] 46/47: doc: Fix typo in Web documentation., Andy Wingo, 2016/05/22
- [Guile-commits] 44/47: Bump user-visible copyright years to 2016., Andy Wingo, 2016/05/22
- [Guile-commits] 03/47: Implement 'string-utf8-length' and 'scm_c_string_utf8_length'., Andy Wingo, 2016/05/22
- [Guile-commits] 12/47: doc: Update libgc URL., Andy Wingo, 2016/05/22
- [Guile-commits] 09/47: Work around requirement that size be non-zero in GDB 'open-memory'., Andy Wingo, 2016/05/22
- [Guile-commits] 07/47: Correct docstring of 'symlink'., Andy Wingo, 2016/05/22
- [Guile-commits] 11/47: Add more R6RS port encoding tests, Andy Wingo, 2016/05/22
- [Guile-commits] 01/47: tests: Use 'pass-if-equal' in web-http chunked encoding tests., Andy Wingo, 2016/05/22
- [Guile-commits] 13/47: Fix typo in manual., Andy Wingo, 2016/05/22
- [Guile-commits] 19/47: Fix uses of 'scm_gc_protect', which does not exist, in the manual., Andy Wingo, 2016/05/22