Skip to content

Commit 38d196a

Browse files
committed
allow pct-encoded entities in fragments
1 parent 8f11597 commit 38d196a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/validators/url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _validate_optionals(path: str, query: str, fragment: str, strict_query: bool
112112
optional_segments &= True
113113
if fragment:
114114
# See RFC3986 Section 3.5 Fragment for allowed characters
115-
optional_segments &= bool(re.fullmatch(r"[0-9a-zA-Z?/:@\-._~!$&'()*+,;=]*", fragment))
115+
optional_segments &= bool(re.fullmatch(r"[0-9a-zA-Z?/:@\-._~%!$&'()*+,;=]*", fragment))
116116
return optional_segments
117117

118118

tests/test_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"https://www.foo.com/bar#/baz/test",
8888
"https://matrix.to/#/!BSqRHgvCtIsGittkBG:talk.puri.sm/$1551464398"
8989
+ "853539kMJNP:matrix.org?via=talk.puri.sm&via=matrix.org&via=disroot.org",
90+
"https://example.org/path#2022%201040%20(Cornelius%20Morgan%20G).pdf",
9091
# when simple_host=True
9192
# "http://localhost",
9293
# "http://localhost:8000",

0 commit comments

Comments
 (0)