Skip to content
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
2 changes: 1 addition & 1 deletion src/rfc3986/abnf_regexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
_AUTHORITY_RE = "[^\\\\/?#]*"
_PATH_RE = "[^?#]*"
_QUERY_RE = "[^#]*"
_FRAGMENT_RE = ".*"
_FRAGMENT_RE = "(?s:.*)"

# Extracted from http://tools.ietf.org/html/rfc3986#appendix-B
COMPONENT_PATTERN_DICT = {
Expand Down
9 changes: 9 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ def test_handles_percent_in_fragment(self, uri_fragment_with_percent):
uri = self.test_class.from_string(uri_fragment_with_percent)
assert uri.fragment == "perc%25ent"

def test_handles_line_terminators_in_fragment(
self, uri_fragment_with_line_terminators
):
"""Test that self.test_class encodes line terminators in the fragment properly"""
ref = self.test_class.from_string(
uri_fragment_with_line_terminators, "utf-8"
)
assert ref.fragment == "%0Afrag%0Ament%0A"


class BaseTestUnsplits:
test_class = None
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def uri_fragment_with_percent(request):
return "https://%s#perc%%ent" % request.param


@pytest.fixture(params=valid_hosts)
def uri_fragment_with_line_terminators(request):
return "https://%s#\nfrag\nment\n" % request.param


@pytest.fixture(params=equivalent_schemes)
def scheme_only(request):
return "%s:" % request.param
Expand Down