From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tobias Geerinckx-Rice Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] web: Hosts ending in a full stop are valid. Date: Sun, 22 Jan 2023 01:00:53 +0100 Message-ID: <20230122000053.17277-1-me@tobias.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20883"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Jan 29 16:06:16 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pM9G2-00059k-S4 for guile-devel@m.gmane-mx.org; Sun, 29 Jan 2023 16:06:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pM9Fp-0004kj-8F; Sun, 29 Jan 2023 10:06:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pM8jY-0003sx-Fi for guile-devel@gnu.org; Sun, 29 Jan 2023 09:32:40 -0500 Original-Received: from tobias.gr ([2a02:c205:2020:6054::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pM8jW-0004RD-F6 for guile-devel@gnu.org; Sun, 29 Jan 2023 09:32:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=sH1LQ+DXU3k/Z mokI4qKFrir6C4bUpQKcxKoFO8TEKU=; h=date:subject:to:from; d=tobias.gr; b=PFOEv4mrOhUmrd/EXJ9hbSbWdGzxk7DwRe0JfqGRoIapXZ1iIsnqksJnCZRXU1WdaQIJ R4foFmKJHXIs1MtqBBHxAXaTxvuQUYZw5J2V56rTl1eRtRa/ansjGcCAsGHmlWa322HCUU ayLlCmfc+LDFCx5K33vuI0ZlPOPfzaF/2XeSxTFsUVgx27rgH7adY7SS2BqPEymtRUZbne Mb+0zuvpsjNukMNtSlVQvYre+0QDqjxAgsRZ8HkUHhKy/fqqxHiNNKuQM6XK/ud5oHMosc GxJs+saj22it2bFmOaieCYjXdap0XV1XF39/OOBdsR8j1WDAJT87O8jsItaDQDIQ== Original-Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 29e07036 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sun, 29 Jan 2023 14:32:32 +0000 (UTC) X-Mailer: git-send-email 2.39.1 Received-SPF: pass client-ip=2a02:c205:2020:6054::1; envelope-from=me@tobias.gr; helo=tobias.gr X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 29 Jan 2023 10:05:59 -0500 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21657 Archived-At: * module/web/uri.scm (valid-host?): Drop one trailing "." before validating. --- module/web/uri.scm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/module/web/uri.scm b/module/web/uri.scm index 8e0b9bee7..c6affa963 100644 --- a/module/web/uri.scm +++ b/module/web/uri.scm @@ -206,13 +206,16 @@ for ‘build-uri’ except there is no scheme." ((regexp-exec ipv6-regexp host) (false-if-exception (inet-pton AF_INET6 host))) (else - (let lp ((start 0)) - (let ((end (string-index host #\. start))) - (if end - (and (regexp-exec domain-label-regexp - (substring host start end)) - (lp (1+ end))) - (regexp-exec top-label-regexp host start))))))) + (let ((fqdn (if (string=? "." (string-take-right host 1)) + (string-drop-right host 1) + host))) + (let lp ((start 0)) + (let ((end (string-index fqdn #\. start))) + (if end + (and (regexp-exec domain-label-regexp + (substring fqdn start end)) + (lp (1+ end))) + (regexp-exec top-label-regexp fqdn start)))))))) (define userinfo-pat (string-append "[" letters digits "_.!~*'();:&=+$,-]+")) base-commit: 5b42f8c154906584455a4989038406c88b723cb0 -- 2.39.1