From 734889358a970f2c10b4d441a2101697528e03fe Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 10 Feb 2020 20:25:51 -0500 Subject: [PATCH] Fix non-compliant Git URL matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RFC 3986 § 2.3 permits more characters in a URL than were matched. This corrects that, though there may be other deficiencies. This was a regression from v1.0.2, where at least “.” was matched without error. --- poetry/vcs/git.py | 4 ++-- tests/vcs/test_git.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/poetry/vcs/git.py b/poetry/vcs/git.py index baa957ed8a6..791e68dd1af 100644 --- a/poetry/vcs/git.py +++ b/poetry/vcs/git.py @@ -12,8 +12,8 @@ "user": r"[a-zA-Z0-9_.-]+", "resource": r"[a-zA-Z0-9_.-]+", "port": r"\d+", - "path": r"[\w\-/\\]+", - "name": r"[\w\-]+", + "path": r"[\w~.\-/\\]+", + "name": r"[\w~.\-]+", "rev": r"[^@#]+", } diff --git a/tests/vcs/test_git.py b/tests/vcs/test_git.py index f0157db364e..062272151fb 100644 --- a/tests/vcs/test_git.py +++ b/tests/vcs/test_git.py @@ -20,6 +20,10 @@ "git+https://user@hostname/project/blah.git", GitUrl("https://user@hostname/project/blah.git", None), ), + ( + "git+https://user@hostname/project~_-.foo/blah~_-.bar.git", + GitUrl("https://user@hostname/project~_-.foo/blah~_-.bar.git", None), + ), ( "git+https://user@hostname:project/blah.git", GitUrl("https://user@hostname/project/blah.git", None), @@ -98,6 +102,18 @@ def test_normalize_url(url, normalized): "https", "hostname", "/project/blah.git", "user", None, "blah", None ), ), + ( + "git+https://user@hostname/project~_-.foo/blah~_-.bar.git", + ParsedUrl( + "https", + "hostname", + "/project~_-.foo/blah~_-.bar.git", + "user", + None, + "blah~_-.bar", + None, + ), + ), ( "git+https://user@hostname:project/blah.git", ParsedUrl(