Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next

* A URL scheme no longer accepts a comma. `+-.` in the scheme check was a character range, so `,` sat between `+` and `.`. ([#199](https://github.com/python-hyper/hyperlink/issues/199))
* CPython 3.9 added to test matrix

## 21.0.0
Expand Down
3 changes: 2 additions & 1 deletion src/hyperlink/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def __nonzero__(self):
r"(\?(?P<query>[^#]*))?"
r"(#(?P<fragment>.*))?$"
)
_SCHEME_RE = re.compile(r"^[a-zA-Z0-9+-.]*$")
# Hyphen is last so it is a literal. "+-." would be the range from "+" to ".".
_SCHEME_RE = re.compile(r"^[a-zA-Z0-9.+-]*$")
_AUTHORITY_RE = re.compile(
r"^(?:(?P<userinfo>[^@/?#]*)@)?"
r"(?P<host>"
Expand Down
5 changes: 5 additions & 0 deletions src/hyperlink/test/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,11 @@ def test_wrong_constructor(self):
with self.assertRaises(ValueError):
# explicitly bad scheme not allowed
URL("HTTP_____more_like_imHoTTeP")
with self.assertRaises(ValueError):
# "+-." is not a range, so a comma is not a scheme character
URL(scheme="ht,tp")
with self.assertRaises(ValueError):
URL.from_text("ht,tp://example.com")

def test_encoded_userinfo(self):
# type: () -> None
Expand Down