Skip to content

Commit 0dc64f8

Browse files
authored
Merge branch 'main' into fix_port_colon
2 parents 9015fab + 3c78778 commit 0dc64f8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/rfc3986/abnf_regexp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
_AUTHORITY_RE = "[^\\\\/?#]*"
4343
_PATH_RE = "[^?#]*"
4444
_QUERY_RE = "[^#]*"
45-
_FRAGMENT_RE = ".*"
45+
_FRAGMENT_RE = "(?s:.*)"
4646

4747
# Extracted from http://tools.ietf.org/html/rfc3986#appendix-B
4848
COMPONENT_PATTERN_DICT = {

tests/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,16 @@ def test_handles_port_but_no_colon(self, uri_with_port_but_no_colon):
156156
raise AssertionError(
157157
"No error thrown from URI with port but no colon"
158158
)
159-
159+
160+
def test_handles_line_terminators_in_fragment(
161+
self, uri_fragment_with_line_terminators
162+
):
163+
"""Test that self.test_class encodes line terminators in the fragment properly"""
164+
ref = self.test_class.from_string(
165+
uri_fragment_with_line_terminators, "utf-8"
166+
)
167+
assert ref.fragment == "%0Afrag%0Ament%0A"
168+
160169

161170
class BaseTestUnsplits:
162171
test_class = None

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ def uri_fragment_with_percent(request):
156156
return "https://%s#perc%%ent" % request.param
157157

158158

159+
@pytest.fixture(params=valid_hosts)
160+
def uri_fragment_with_line_terminators(request):
161+
return "https://%s#\nfrag\nment\n" % request.param
162+
163+
159164
@pytest.fixture(params=equivalent_schemes)
160165
def scheme_only(request):
161166
return "%s:" % request.param

0 commit comments

Comments
 (0)