fix(capture): remove empty URL userinfo markers
This commit is contained in:
@@ -106,7 +106,7 @@ def without_userinfo(value, base_scheme=None):
|
|||||||
while end < len(parsed_text) and parsed_text[end] not in terminators:
|
while end < len(parsed_text) and parsed_text[end] not in terminators:
|
||||||
end += 1
|
end += 1
|
||||||
at = parsed_text.rfind("@", start, end)
|
at = parsed_text.rfind("@", start, end)
|
||||||
if at <= start:
|
if at < start:
|
||||||
return value
|
return value
|
||||||
parsed_offset = 0
|
parsed_offset = 0
|
||||||
raw_start = 0
|
raw_start = 0
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ class TransportUserinfoTests(unittest.TestCase):
|
|||||||
text, _sidecar, _redactions = location(b"https://user:pw@example.test/a@b")
|
text, _sidecar, _redactions = location(b"https://user:pw@example.test/a@b")
|
||||||
self.assertEqual(text, "https://example.test/a@b")
|
self.assertEqual(text, "https://example.test/a@b")
|
||||||
|
|
||||||
|
def test_empty_userinfo_marker_is_removed(self):
|
||||||
|
self.assertEqual(
|
||||||
|
capture.without_userinfo("https://@host"), "https://host"
|
||||||
|
)
|
||||||
|
|
||||||
def test_special_schemes_skip_leading_slashes_before_userinfo(self):
|
def test_special_schemes_skip_leading_slashes_before_userinfo(self):
|
||||||
for value, expected in [
|
for value, expected in [
|
||||||
(b"https://\\user:pass@host/path", b"https://\\host/path"),
|
(b"https://\\user:pass@host/path", b"https://\\host/path"),
|
||||||
|
|||||||
Reference in New Issue
Block a user