GNU bug report logs - #53201
string->uri-reference rejects domain names with final ‘.’

Previous Next

Package: guile;

Reported by: Tobias Geerinckx-Rice <me <at> tobias.gr>

Date: Wed, 12 Jan 2022 05:34:02 UTC

Severity: normal

To reply to this bug, email your comments to 53201 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#53201; Package guile. (Wed, 12 Jan 2022 05:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Geerinckx-Rice <me <at> tobias.gr>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Wed, 12 Jan 2022 05:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: bug-guile <at> gnu.org
Subject: string->uri-reference rejects domain names with final
 ‘.’
Date: Wed, 12 Jan 2022 03:56:17 +0100
[Message part 1 (text/plain, inline)]
Guilers,

What the subject says :-)  Omitting the final dot is optional (and 
common), not mandatory.

 scheme@(guile-user)> (string->uri-reference "http://x.org")
 $1 = #<<uri> … host: "x.org" …>

 scheme@(guile-user)> (string->uri-reference "http://x.org.")
 $2 = #f ; wrong!

This actually breaks redirects in the wild:

Starting download […]
From 
https://pyropus.ca/software/getmail/old-versions/getmail-5.16.tar.gz...
Bad uri-reference header component:
https://pyropus.ca./software/getmail/old-versions/getmail-5.16.tar.gz

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#53201; Package guile. (Thu, 27 Jan 2022 00:41:01 GMT) Full text and rfc822 format available.

Message #8 received at 53201 <at> debbugs.gnu.org (full text, mbox):

From: dsmich <at> roadrunner.com
To: "'Tobias Geerinckx-Rice'" <me <at> tobias.gr>
Cc: "'53201 <at> debbugs.gnu.org'" <53201 <at> debbugs.gnu.org>
Subject: RE: bug#53201: string->uri-reference rejects domain names with final ‘.’
Date: Thu, 27 Jan 2022 00:40:03 +0000
[Message part 1 (text/plain, inline)]
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")


[Message part 2 (text/html, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#53201; Package guile. (Fri, 28 Jan 2022 00:31:01 GMT) Full text and rfc822 format available.

Message #11 received at 53201 <at> debbugs.gnu.org (full text, mbox):

From: dsmich <at> roadrunner.com
To: "'Tobias Geerinckx-Rice'" <me <at> tobias.gr>
Cc: "'53201 <at> debbugs.gnu.org'" <53201 <at> debbugs.gnu.org>
Subject: RE: bug#53201: string->uri-reference rejects domain names with final ‘.’
Date: Fri, 28 Jan 2022 00:30:41 +0000
[Message part 1 (text/plain, inline)]
New patch. Now with 3 test cases!

-Dale


[Message part 2 (text/html, inline)]
[0001-Allow-trailing-.-in-urls.patch (text/x-patch, attachment)]

This bug report was last modified 2 years and 97 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.