mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
RFC 822 allows single digit days of the month
* module/web/http.scm (parse-rfc-822-date): Add single digit day conditional. * test-suite/tests/web-http.test("general headers"): Add test.
This commit is contained in:
parent
86b4309b71
commit
cb7bcfca35
2 changed files with 22 additions and 9 deletions
|
@ -702,15 +702,25 @@ ordered alist."
|
||||||
;; 0 1 2
|
;; 0 1 2
|
||||||
(define (parse-rfc-822-date str)
|
(define (parse-rfc-822-date str)
|
||||||
;; We could verify the day of the week but we don't.
|
;; We could verify the day of the week but we don't.
|
||||||
(if (not (string-match? str "aaa, dd aaa dddd dd:dd:dd GMT"))
|
(cond ((string-match? str "aaa, dd aaa dddd dd:dd:dd GMT")
|
||||||
(bad-header 'date str))
|
(let ((date (parse-non-negative-integer str 5 7))
|
||||||
(let ((date (parse-non-negative-integer str 5 7))
|
(month (parse-month str 8 11))
|
||||||
(month (parse-month str 8 11))
|
(year (parse-non-negative-integer str 12 16))
|
||||||
(year (parse-non-negative-integer str 12 16))
|
(hour (parse-non-negative-integer str 17 19))
|
||||||
(hour (parse-non-negative-integer str 17 19))
|
(minute (parse-non-negative-integer str 20 22))
|
||||||
(minute (parse-non-negative-integer str 20 22))
|
(second (parse-non-negative-integer str 23 25)))
|
||||||
(second (parse-non-negative-integer str 23 25)))
|
(make-date 0 second minute hour date month year 0)))
|
||||||
(make-date 0 second minute hour date month year 0)))
|
((string-match? str "aaa, d aaa dddd dd:dd:dd GMT")
|
||||||
|
(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 16 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 0)))
|
||||||
|
(else
|
||||||
|
(bad-header 'date str) ; prevent tail call
|
||||||
|
#f)))
|
||||||
|
|
||||||
;; RFC 850, updated by RFC 1036
|
;; RFC 850, updated by RFC 1036
|
||||||
;; Sunday, 06-Nov-94 08:49:37 GMT
|
;; Sunday, 06-Nov-94 08:49:37 GMT
|
||||||
|
|
|
@ -89,6 +89,9 @@
|
||||||
(pass-if-parse date "Tue, 15 Nov 1994 08:12:31 GMT"
|
(pass-if-parse date "Tue, 15 Nov 1994 08:12:31 GMT"
|
||||||
(string->date "Tue, 15 Nov 1994 08:12:31 +0000"
|
(string->date "Tue, 15 Nov 1994 08:12:31 +0000"
|
||||||
"~a, ~d ~b ~Y ~H:~M:~S ~z"))
|
"~a, ~d ~b ~Y ~H:~M:~S ~z"))
|
||||||
|
(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"))
|
||||||
(pass-if-parse-error date "Tue, 15 Nov 1994 08:12:31 EST" date)
|
(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")
|
(pass-if-any-error date "Tue, 15 Qux 1994 08:12:31 EST")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue