From: "Ludovic Courtès" <ludo@gnu.org>
To: Julien Lepiller <julien@lepiller.eu>
Cc: 40582@debbugs.gnu.org
Subject: bug#40582: Valid URIs are rejected
Date: Wed, 17 Jun 2020 23:57:33 +0200 [thread overview]
Message-ID: <878sglpd82.fsf@gnu.org> (raw)
In-Reply-To: <3EFDD2B8-58F2-41E1-997B-76098A9A3715@lepiller.eu> (Julien Lepiller's message of "Sun, 12 Apr 2020 15:44:31 -0400")
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
Hi Julien,
Julien Lepiller <julien@lepiller.eu> skribis:
> Using (web uri), I was trying to parse "uri://a/c". Reading RFC3986, it should be a valid URI (see rule for reg-name in 3.2.2). However, passing it to string->uri results in #f. I've tracked this down to valid-host? which returns #f for "a".
>
> The reason is that the regexp checking if the host is an ipv6 matches "a", which shouldn't happen because a is not an ipv6 address. Indeed, when I try (string->uri "uri://g/b"), I get the expected result.
Right. ‘authority-regexp’ is fine, but ‘ipv6-regexp’, used by
‘valid-host?’, was too lax and would match “a” because it’s an hex digit
sequence.
The regexp below is still an approximation, but I think a better one.
Can you confirm?
Thanks,
Ludo’.
[-- Attachment #2: Type: text/x-patch, Size: 1558 bytes --]
diff --git a/module/web/uri.scm b/module/web/uri.scm
index b4b89b9cc..d76432737 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -188,7 +188,7 @@ for ‘build-uri’ except there is no scheme."
(define ipv4-regexp
(make-regexp (string-append "^([" digits ".]+)$")))
(define ipv6-regexp
- (make-regexp (string-append "^([" hex-digits ":.]+)$")))
+ (make-regexp (string-append "^([" hex-digits "]*:[" hex-digits ":.]+)$")))
(define domain-label-regexp
(make-regexp
(string-append "^[" letters digits "]"
diff --git a/test-suite/tests/web-uri.test b/test-suite/tests/web-uri.test
index 94778acac..95fd82f16 100644
--- a/test-suite/tests/web-uri.test
+++ b/test-suite/tests/web-uri.test
@@ -1,6 +1,6 @@
;;;; web-uri.test --- URI library -*- mode: scheme; coding: utf-8; -*-
;;;;
-;;;; Copyright (C) 2010-2012, 2014, 2017, 2019 Free Software Foundation, Inc.
+;;;; Copyright (C) 2010-2012, 2014, 2017, 2019, 2020 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -179,6 +179,13 @@
#:port 22
#:path "/baz"))
+ (pass-if-equal "xyz://abc/x/y/z" ;<https://bugs.gnu.org/40582>
+ (list 'xyz "abc" "/x/y/z")
+ (let ((uri (string->uri "xyz://abc/x/y/z")))
+ (list (uri-scheme uri)
+ (uri-host uri)
+ (uri-path uri))))
+
(pass-if "http://bad.host.1"
(not (string->uri "http://bad.host.1")))
next prev parent reply other threads:[~2020-06-17 21:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 19:44 bug#40582: Valid URIs are rejected Julien Lepiller
2020-06-17 21:57 ` Ludovic Courtès [this message]
2020-06-18 1:17 ` Julien Lepiller
2020-06-18 15:07 ` Ludovic Courtès
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=878sglpd82.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=40582@debbugs.gnu.org \
--cc=julien@lepiller.eu \
/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).