unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: dsmich@roadrunner.com
To: "'Tobias Geerinckx-Rice'" <me@tobias.gr>
Cc: "'53201@debbugs.gnu.org'" <53201@debbugs.gnu.org>
Subject: bug#53201: string->uri-reference rejects domain names with final ‘.’
Date: Thu, 27 Jan 2022 00:40:03 +0000	[thread overview]
Message-ID: <cad498fa10c07336957258006a96632d9c90e510@webmail> (raw)
In-Reply-To: <877db5ldok.fsf@nckx>

[-- Attachment #1: Type: text/plain, Size: 1450 bytes --]

Probably not the best fix. Seems to work. Includes a few tests.

-Dale

diff --git a/module/web/uri.scm b/module/web/uri.scm
index 8e0b9bee7..d6758fcc6 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -212,7 +212,9 @@ for ‘build-uri’ except there is no scheme."
 (and (regexp-exec domain-label-regexp
 (substring host start end))
 (lp (1+ end)))
- (regexp-exec top-label-regexp host start)))))))
+ (if (< start (string-length host))
+ (regexp-exec top-label-regexp host start)
+ #t)))))))

 (define userinfo-pat
 (string-append "[" letters digits "_.!~*'();:&=+$,-]+"))
diff --git a/test-suite/tests/web-uri.test
b/test-suite/tests/web-uri.test
index 95fd82f16..c49142d48 100644
--- a/test-suite/tests/web-uri.test
+++ b/test-suite/tests/web-uri.test
@@ -367,6 +367,9 @@
 (pass-if "//bad.host.1"
 (not (string->uri-reference "//bad.host.1")))

+ (pass-if "//bad.host.."
+ (not (string->uri-reference "//bad.host..")))
+
 (pass-if "http://1.good.host"
 (uri=? (string->uri-reference "http://1.good.host")
 #:scheme 'http #:host "1.good.host" #:path ""))
@@ -375,6 +378,10 @@
 (uri=? (string->uri-reference "//1.good.host")
 #:host "1.good.host" #:path ""))

+ (pass-if "//1.good.host."
+ (uri=? (string->uri-reference "//1.good.host.")
+ #:host "1.good.host." #:path ""))
+
 (when (memq 'socket *features*)
 (pass-if "http://192.0.2.1"
 (uri=? (string->uri-reference "http://192.0.2.1")



[-- Attachment #2: Type: text/html, Size: 2756 bytes --]

  reply	other threads:[~2022-01-27  0:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12  2:56 bug#53201: string->uri-reference rejects domain names with final ‘.’ Tobias Geerinckx-Rice via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2022-01-27  0:40 ` dsmich [this message]
2022-01-28  0:30 ` dsmich

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=cad498fa10c07336957258006a96632d9c90e510@webmail \
    --to=dsmich@roadrunner.com \
    --cc=53201@debbugs.gnu.org \
    --cc=me@tobias.gr \
    /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).