From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#13544: (web http) fails to parse numeric timezones in Date header Date: Thu, 24 Jan 2013 23:13:39 +0100 Message-ID: <8738xqjkks.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1359066199 8557 80.91.229.3 (24 Jan 2013 22:23:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jan 2013 22:23:19 +0000 (UTC) Cc: Cyril Roelandt To: 13544@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jan 24 23:23:38 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TyVCr-0001EC-L6 for guile-bugs@m.gmane.org; Thu, 24 Jan 2013 23:23:37 +0100 Original-Received: from localhost ([::1]:51319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyVCa-0000W8-8M for guile-bugs@m.gmane.org; Thu, 24 Jan 2013 17:23:20 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:34311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyVCN-0000Ui-K9 for bug-guile@gnu.org; Thu, 24 Jan 2013 17:23:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyVCE-0007ri-7O for bug-guile@gnu.org; Thu, 24 Jan 2013 17:23:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyVCE-0007rS-2q for bug-guile@gnu.org; Thu, 24 Jan 2013 17:22:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TyVCI-0000Dh-GW for bug-guile@gnu.org; Thu, 24 Jan 2013 17:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 24 Jan 2013 22:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13544 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1359066155792 (code B ref -1); Thu, 24 Jan 2013 22:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jan 2013 22:22:35 +0000 Original-Received: from localhost ([127.0.0.1]:48254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TyVBq-0000Ci-FD for submit@debbugs.gnu.org; Thu, 24 Jan 2013 17:22:34 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50876) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TyVBo-0000CY-28 for submit@debbugs.gnu.org; Thu, 24 Jan 2013 17:22:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyVBg-0007i1-RM for submit@debbugs.gnu.org; Thu, 24 Jan 2013 17:22:27 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:60840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyVBg-0007hh-NO for submit@debbugs.gnu.org; Thu, 24 Jan 2013 17:22:24 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyVBe-0000O3-PU for bug-guile@gnu.org; Thu, 24 Jan 2013 17:22:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyVBa-0007h1-C0 for bug-guile@gnu.org; Thu, 24 Jan 2013 17:22:22 -0500 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:14311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyV3M-0005R0-PJ for bug-guile@gnu.org; Thu, 24 Jan 2013 17:13:48 -0500 X-IronPort-AV: E=Sophos;i="4.84,532,1355094000"; d="scan'208";a="191412879" Original-Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 24 Jan 2013 23:13:39 +0100 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 5 =?UTF-8?Q?Pluvi=C3=B4se?= an 221 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6710 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --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=E2=80=99s a tentative patch to fix it: --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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)) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=E2=80=99. --=-=-=--