unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] web: Hosts ending in a full stop are valid.
@ 2023-01-22  0:00 Tobias Geerinckx-Rice
  0 siblings, 0 replies; only message in thread
From: Tobias Geerinckx-Rice @ 2023-01-22  0:00 UTC (permalink / raw)
  To: guile-devel

* 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




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-22  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-22  0:00 [PATCH] web: Hosts ending in a full stop are valid Tobias Geerinckx-Rice

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).