From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#40582: Valid URIs are rejected Date: Wed, 17 Jun 2020 23:57:33 +0200 Message-ID: <878sglpd82.fsf@gnu.org> References: <3EFDD2B8-58F2-41E1-997B-76098A9A3715@lepiller.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="80493"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 40582@debbugs.gnu.org To: Julien Lepiller Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Wed Jun 17 23:58:09 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlg4O-000KpH-NH for guile-bugs@m.gmane-mx.org; Wed, 17 Jun 2020 23:58:08 +0200 Original-Received: from localhost ([::1]:44180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlg4N-0003qi-LZ for guile-bugs@m.gmane-mx.org; Wed, 17 Jun 2020 17:58:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlg4I-0003nt-SA for bug-guile@gnu.org; Wed, 17 Jun 2020 17:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlg4I-0000uV-HJ for bug-guile@gnu.org; Wed, 17 Jun 2020 17:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jlg4I-000860-Cc for bug-guile@gnu.org; Wed, 17 Jun 2020 17:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 17 Jun 2020 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40582 X-GNU-PR-Package: guile Original-Received: via spool by 40582-submit@debbugs.gnu.org id=B40582.159243106831099 (code B ref 40582); Wed, 17 Jun 2020 21:58:02 +0000 Original-Received: (at 40582) by debbugs.gnu.org; 17 Jun 2020 21:57:48 +0000 Original-Received: from localhost ([127.0.0.1]:52334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlg44-00085X-5s for submit@debbugs.gnu.org; Wed, 17 Jun 2020 17:57:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlg40-00085I-DW for 40582@debbugs.gnu.org; Wed, 17 Jun 2020 17:57:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52815) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlg3u-0000tW-Fv; Wed, 17 Jun 2020 17:57:38 -0400 Original-Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=58746 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jlg3r-0003a6-Sh; Wed, 17 Jun 2020 17:57:37 -0400 In-Reply-To: <3EFDD2B8-58F2-41E1-997B-76098A9A3715@lepiller.eu> (Julien Lepiller's message of "Sun, 12 Apr 2020 15:44:31 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9798 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Julien, Julien Lepiller skribis: > Using (web uri), I was trying to parse "uri://a/c". Reading RFC3986, it s= hould 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 r= eturns #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 t= ry (string->uri "uri://g/b"), I get the expected result. Right. =E2=80=98authority-regexp=E2=80=99 is fine, but =E2=80=98ipv6-regex= p=E2=80=99, used by =E2=80=98valid-host?=E2=80=99, was too lax and would match =E2=80=9Ca=E2=80= =9D because it=E2=80=99s an hex digit sequence. The regexp below is still an approximation, but I think a better one. Can you confirm? Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =E2=80=98build-uri=E2=80=99 except there is no sche= me." (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 Founda= tion, 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")) =20 + (pass-if-equal "xyz://abc/x/y/z" ; + (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"))) =20 --=-=-=--