Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle escaped characters in repositories URL #524

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/poetry/core/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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"[^@#]+?"
SUBDIR = r"[\w\-/\\]+"

Expand Down
30 changes: 16 additions & 14 deletions tests/vcs/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
GitUrl("https://user@hostname/project/blah.git", None, None),
),
(
"git+https://user@hostname/project~_-.foo/blah~_-.bar.git",
GitUrl("https://user@hostname/project~_-.foo/blah~_-.bar.git", None, None),
"git+https://user@hostname/project%20~_-.foo/blah%20~_-.bar.git",
GitUrl(
"https://user@hostname/project%20~_-.foo/blah%20~_-.bar.git", None, None
),
),
(
"git+https://user@hostname:project/blah.git",
Expand Down Expand Up @@ -151,7 +153,7 @@
],
)
def test_normalize_url(url: str, normalized: GitUrl) -> None:
assert normalized == Git.normalize_url(url)
assert Git.normalize_url(url) == normalized


@pytest.mark.parametrize(
Expand All @@ -176,14 +178,14 @@ def test_normalize_url(url: str, normalized: GitUrl) -> None:
),
),
(
"git+https://user@hostname/project~_-.foo/blah~_-.bar.git",
"git+https://user@hostname/project%20~_-.foo/blah%20~_-.bar.git",
ParsedUrl(
"https",
"hostname",
"/project~_-.foo/blah~_-.bar.git",
"/project%20~_-.foo/blah%20~_-.bar.git",
"user",
None,
"blah~_-.bar",
"blah%20~_-.bar",
None,
),
),
Expand Down Expand Up @@ -394,14 +396,14 @@ def test_normalize_url(url: str, normalized: GitUrl) -> None:
)
def test_parse_url(url: str, parsed: ParsedUrl) -> None:
result = ParsedUrl.parse(url)
assert parsed.name == result.name
assert parsed.pathname == result.pathname
assert parsed.port == result.port
assert parsed.protocol == result.protocol
assert parsed.resource == result.resource
assert parsed.rev == result.rev
assert parsed.url == result.url
assert parsed.user == result.user
assert result.name == parsed.name
assert result.pathname == parsed.pathname
assert result.port == parsed.port
assert result.protocol == parsed.protocol
assert result.resource == parsed.resource
assert result.rev == parsed.rev
assert result.url == parsed.url
assert result.user == parsed.user


def test_parse_url_should_fail() -> None:
Expand Down