web: Accept URI host names consisting only of hex digits.

Fixes <https://bugs.gnu.org/40582>.
Reported by Julien Lepiller <julien@lepiller.eu>.

Previously, a host part consisting of hex digits would be mistaken as an
IPv6 address and rejected by 'valid-host?'.

* module/web/uri.scm (ipv6-regexp): Add colon.
* test-suite/tests/web-uri.test ("string->uri")["xyz://abc/x/y/z"]: New
test.
* NEWS: Update.
This commit is contained in:
Ludovic Courtès 2020-06-18 17:02:07 +02:00
commit 1ab2105339
3 changed files with 13 additions and 3 deletions

View file

@ -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")))