unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Tobias Geerinckx-Rice <me@tobias.gr>
To: guile-devel@gnu.org
Subject: [PATCH] web: Hosts ending in a full stop are valid.
Date: Sun, 22 Jan 2023 01:00:53 +0100	[thread overview]
Message-ID: <20230122000053.17277-1-me@tobias.gr> (raw)

* 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




                 reply	other threads:[~2023-01-22  0:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230122000053.17277-1-me@tobias.gr \
    --to=me@tobias.gr \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).