X-Loop: help-debbugs@HIDDEN Subject: bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase Resent-From: Alexey Abramov <levenson@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Mon, 11 Oct 2021 07:05:01 +0000 Resent-Message-ID: <handler.51133.B.163393586914403 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 51133 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 51133 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-guile@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.163393586914403 (code B ref -1); Mon, 11 Oct 2021 07:05:01 +0000 Received: (at submit) by debbugs.gnu.org; 11 Oct 2021 07:04:29 +0000 Received: from localhost ([127.0.0.1]:56286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1mZpMK-0003kF-SW for submit <at> debbugs.gnu.org; Mon, 11 Oct 2021 03:04:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:35324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <levenson@HIDDEN>) id 1mZpMH-0003k5-1a for submit <at> debbugs.gnu.org; Mon, 11 Oct 2021 03:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <levenson@HIDDEN>) id 1mZpMF-00080h-R4 for bug-guile@HIDDEN; Mon, 11 Oct 2021 03:04:24 -0400 Received: from mail.mmer.org ([178.22.65.174]:48654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <levenson@HIDDEN>) id 1mZpME-00050Q-2x for bug-guile@HIDDEN; Mon, 11 Oct 2021 03:04:23 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 29d24c22 for <bug-guile@HIDDEN>; Mon, 11 Oct 2021 07:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=g55cgYrk7ZeTKFn4b5yQrg7N3luRB9A6Tn9wpuS1zk4=; b=R+wP oUEA9svnMFg1U/lm2V8mPDp6LWrgO1TlPfw1p6XIhayHMnL58tFwHpxZSrGUZHl+ v6krf8hYtU7qNOR3bSzg/GiLxl3/HCNw63o7qHetwXWCJRF1TaKvlnla+8wqylMW cRgq8U09fwlPhPcIbAKi1jEPZy39/hYk0shpI70= Received: from delta (j74182.upc-j.chello.nl [24.132.74.182]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 4d492ff5 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <bug-guile@HIDDEN>; Mon, 11 Oct 2021 07:04:10 +0000 (UTC) From: Alexey Abramov <levenson@HIDDEN> Date: Mon, 11 Oct 2021 09:03:55 +0200 Message-Id: <20211011070355.20408-1-levenson@HIDDEN> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=178.22.65.174; envelope-from=levenson@HIDDEN; helo=mail.mmer.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) * module/web/http.scm (read-response-line): Use the end of the string, in case a line doesn't have char-set:whitespace at the end. * test-suite/tests/web-http.test ("read-response-line"): Add test. --- module/web/http.scm | 6 ++++-- test-suite/tests/web-http.test | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/module/web/http.scm b/module/web/http.scm index 4276e1744..7443bd6a4 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -1187,8 +1187,10 @@ values: the HTTP version, the response code, and the (possibly empty) \"reason phrase\"." (let* ((line (read-header-line port)) (d0 (string-index line char-set:whitespace)) ; "delimiter zero" - (d1 (and d0 (string-index line char-set:whitespace - (skip-whitespace line d0))))) + (d1 (and d0 (or (string-index line char-set:whitespace + (skip-whitespace line d0)) + ;; tolerate responses with empty "reason phrase" + (string-length line))))) (unless (and d0 d1) (bad-response "Bad Response-Line: ~s" line)) (values (parse-http-version line 0 d0) diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test index 63377349c..6d8cd1642 100644 --- a/test-suite/tests/web-http.test +++ b/test-suite/tests/web-http.test @@ -216,6 +216,8 @@ ;; Empty reason phrases are valid; see <http://bugs.gnu.org/22273>. (pass-if-read-response-line "HTTP/1.1 302 " + (1 . 1) 302 "") + (pass-if-read-response-line "HTTP/1.1 302" (1 . 1) 302 "")) (with-test-prefix "write-response-line" -- 2.31.1
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Alexey Abramov <levenson@HIDDEN> Subject: bug#51133: Acknowledgement ([PATCH 1/1] Tolerate http response line without reason phrase) Message-ID: <handler.51133.B.163393586914403.ack <at> debbugs.gnu.org> References: <20211011070355.20408-1-levenson@HIDDEN> X-Gnu-PR-Message: ack 51133 X-Gnu-PR-Package: guile X-Gnu-PR-Keywords: patch Reply-To: 51133 <at> debbugs.gnu.org Date: Mon, 11 Oct 2021 07:05:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-guile@HIDDEN If you wish to submit further information on this problem, please send it to 51133 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 51133: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D51133 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase Resent-From: jakub-w@HIDDEN Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Tue, 12 Oct 2021 08:03:02 +0000 Resent-Message-ID: <handler.51133.B.163402573517389 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 51133 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 51133 <at> debbugs.gnu.org Cc: levenson@HIDDEN X-Debbugs-Original-To: bug-guile@HIDDEN X-Debbugs-Original-Cc: 51133 <at> debbugs.gnu.org, Alexey Abramov <levenson@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.163402573517389 (code B ref -1); Tue, 12 Oct 2021 08:03:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Oct 2021 08:02:15 +0000 Received: from localhost ([127.0.0.1]:33381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1maCjm-0004WP-Ps for submit <at> debbugs.gnu.org; Tue, 12 Oct 2021 04:02:14 -0400 Received: from lists.gnu.org ([209.51.188.17]:40276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <jakub-w@HIDDEN>) id 1maCjk-0004WC-PM for submit <at> debbugs.gnu.org; Tue, 12 Oct 2021 04:02:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jakub-w@HIDDEN>) id 1maCjk-0007jL-Ex for bug-guile@HIDDEN; Tue, 12 Oct 2021 04:02:12 -0400 Received: from mx1.riseup.net ([198.252.153.129]:41162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jakub-w@HIDDEN>) id 1maCji-0003ow-8e for bug-guile@HIDDEN; Tue, 12 Oct 2021 04:02:11 -0400 Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4HT7Rf0TSxzF4qg; Tue, 12 Oct 2021 01:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1634025726; bh=s8zkjk0AO7eaMmPYhadGYLrdqJMODC8xoyhXPXP6eBI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=RomA2obR3YhPrjafylbNUwkfbTYpMMKMxihPbtzNCICnXv4YUPRKbHg6F16qK4YHc yKEoJ4yiiQjrjdRQzpqR38E3N2pj3YYLcz/83AQBZkjUc9v4wqSgCO3vG/bmNsfRpM UWtnlXYM58n99iDMfprxb7STVmMnLqxXf2+Y34Pw= X-Riseup-User-ID: 9009DAFA6C0F5E1A62075D39C4858D5F3751B8E658D2C49A0106135606A3D0B2 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4HT7Rc61T8z5wDQ; Tue, 12 Oct 2021 01:02:04 -0700 (PDT) From: jakub-w@HIDDEN References: <20211011070355.20408-1-levenson@HIDDEN> Date: Tue, 12 Oct 2021 10:01:03 +0200 In-Reply-To: <20211011070355.20408-1-levenson@HIDDEN> (Alexey Abramov via's message of "Mon, 11 Oct 2021 09:03:55 +0200") Message-ID: <87h7dmhdts.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=198.252.153.129; envelope-from=jakub-w@HIDDEN; helo=mx1.riseup.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) I don't think the reason phrase is optional, even though it can be just a whitespace. Even if I'm not mistaken, however, I don't see the reason for Guile not to be able to parse the status line without a space at the end. Aside from that consider a string "HTTP/1.1 ", which should be a bad response because the status code should definitely be obligatory, however it passes through the (and d0 d1) check after applying this patch.
X-Loop: help-debbugs@HIDDEN Subject: bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase Resent-From: jakub-w@HIDDEN Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Tue, 12 Oct 2021 08:03:02 +0000 Resent-Message-ID: <handler.51133.B51133.163402573217375 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 51133 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 51133 <at> debbugs.gnu.org Cc: levenson@HIDDEN X-Debbugs-Original-To: bug-guile@HIDDEN X-Debbugs-Original-Cc: 51133 <at> debbugs.gnu.org, Alexey Abramov <levenson@HIDDEN> Received: via spool by 51133-submit <at> debbugs.gnu.org id=B51133.163402573217375 (code B ref 51133); Tue, 12 Oct 2021 08:03:02 +0000 Received: (at 51133) by debbugs.gnu.org; 12 Oct 2021 08:02:12 +0000 Received: from localhost ([127.0.0.1]:33378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1maCjk-0004WA-Jp for submit <at> debbugs.gnu.org; Tue, 12 Oct 2021 04:02:12 -0400 Received: from mx1.riseup.net ([198.252.153.129]:40652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <jakub-w@HIDDEN>) id 1maCjj-0004Vx-HR for 51133 <at> debbugs.gnu.org; Tue, 12 Oct 2021 04:02:11 -0400 Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4HT7Rf0TSxzF4qg; Tue, 12 Oct 2021 01:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1634025726; bh=s8zkjk0AO7eaMmPYhadGYLrdqJMODC8xoyhXPXP6eBI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=RomA2obR3YhPrjafylbNUwkfbTYpMMKMxihPbtzNCICnXv4YUPRKbHg6F16qK4YHc yKEoJ4yiiQjrjdRQzpqR38E3N2pj3YYLcz/83AQBZkjUc9v4wqSgCO3vG/bmNsfRpM UWtnlXYM58n99iDMfprxb7STVmMnLqxXf2+Y34Pw= X-Riseup-User-ID: 9009DAFA6C0F5E1A62075D39C4858D5F3751B8E658D2C49A0106135606A3D0B2 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4HT7Rc61T8z5wDQ; Tue, 12 Oct 2021 01:02:04 -0700 (PDT) From: jakub-w@HIDDEN References: <20211011070355.20408-1-levenson@HIDDEN> Date: Tue, 12 Oct 2021 10:01:03 +0200 In-Reply-To: <20211011070355.20408-1-levenson@HIDDEN> (Alexey Abramov via's message of "Mon, 11 Oct 2021 09:03:55 +0200") Message-ID: <87h7dmhdts.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) I don't think the reason phrase is optional, even though it can be just a whitespace. Even if I'm not mistaken, however, I don't see the reason for Guile not to be able to parse the status line without a space at the end. Aside from that consider a string "HTTP/1.1 ", which should be a bad response because the status code should definitely be obligatory, however it passes through the (and d0 d1) check after applying this patch.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.