emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#13544: closed ((web http) fails to parse numeric t


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#13544: closed ((web http) fails to parse numeric timezones in Date header)
Date: Wed, 27 Mar 2013 15:28:02 +0000

Your message dated Wed, 27 Mar 2013 16:25:12 +0100
with message-id <address@hidden>
and subject line Re: bug#13544: (web http) fails to parse numeric timezones in 
Date header
has caused the debbugs.gnu.org bug report #13544,
regarding (web http) fails to parse numeric timezones in Date header
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
13544: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13544
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: (web http) fails to parse numeric timezones in Date header Date: Thu, 24 Jan 2013 23:13:39 +0100 User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (use-modules(web client)(web uri))
scheme@(guile-user)> (http-get (string->uri "http://www.sqlite.org/";))
web/http.scm:768:6: In procedure parse-asctime-date:
web/http.scm:768:6: Bad Date header: Thu, 24  Jan 2013 21:53:01 +0000
--8<---------------cut here---------------end--------------->8---

RFC 1123 reads:

       There is a strong trend towards the use of numeric timezone
       indicators, and implementations SHOULD use numeric timezones
       instead of timezone names.  However, all implementations MUST
       accept either notation.  If timezone names are used, they MUST
       be exactly as defined in RFC-822.

Here’s a tentative patch to fix it:

diff --git a/module/web/http.scm b/module/web/http.scm
index 216fddd..2ab5bd0 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1,6 +1,6 @@
 ;;; HTTP messages
 
-;; Copyright (C)  2010, 2011, 2012 Free Software Foundation, Inc.
+;; Copyright (C)  2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -732,6 +732,20 @@ 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 0)))
+        ((string-match? str "aaa, dd aaa dddd dd:dd:dd .0000")
+         (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 17 19))
+               (minute (parse-non-negative-integer str 20 22))
+               (second (parse-non-negative-integer str 23 25))
+               (tz (parse-non-negative-integer str 28 31))
+               (tz-sign (case (string-ref str 27)
+                          ((#\+) +1)
+                          ((#\-) -1)
+                          (else (bad-header 'date str) #f))))
+           (make-date 0 second minute hour date month year
+                      (* tz-sign tz))))
         (else
          (bad-header 'date str)         ; prevent tail call
          #f)))
@@ -778,7 +792,8 @@ as an ordered alist."
     (make-date 0 second minute hour date month year 0)))
 
 (define (parse-date str)
-  (if (string-suffix? " GMT" str)
+  (if (or (string-suffix? " GMT" str)
+          (string-match "[+-][0-9]{4}$" str))
       (let ((comma (string-index str #\,)))
         (cond ((not comma) (bad-header 'date str))
               ((= comma 3) (parse-rfc-822-date str))
Problem is, this particular example has another problem: it has an extra
space before the month name.

How is this best addressed?  Should the parser be more tolerant,
possibly using plain regexps?

Thanks,
Ludo’.

--- End Message ---
--- Begin Message --- Subject: Re: bug#13544: (web http) fails to parse numeric timezones in Date header Date: Wed, 27 Mar 2013 16:25:12 +0100 User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)
Daniel Hartwig <address@hidden> skribis:

>>From 430fc9498ee08f6d06b5ec494a5d65e395c6c067 Mon Sep 17 00:00:00 2001
> From: Daniel Hartwig <address@hidden>
> Date: Fri, 15 Mar 2013 22:25:10 +0800
> Subject: [PATCH] web http: parse numeric time zones in headers
>
> * module/web/http.scm (parse-zone-offset, normalize-date): New
>   procedures.
>   (parse-rfc-822-date, parse-rfc-850-date, parse-date): Update.
> * test-suite/tests/web-http.test ("general headers"): Add test.

I’ve pushed the patch, so I guess we can close this bug now.

Thanks!

Ludo’.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]