fix(capture): preserve file-relative path evidence after separators

This commit is contained in:
morluto 2026-10-13 23:02:00 +08:00
parent 0aff997b31
commit 4d5d1f5daa
2 changed files with 11 additions and 0 deletions

View File

@ -79,6 +79,8 @@ def authority_start(text, base_scheme=None):
if prefix is None:
return None
start = prefix.end()
if base_scheme == "file":
return start, True
while start < len(text) and text[start] in "/\\":
start += 1
return start, True

View File

@ -148,6 +148,15 @@ class TransportUserinfoTests(unittest.TestCase):
self.assertEqual(sidecar["state"], "redacted")
self.assertEqual(len(redactions), 1)
def test_file_base_keeps_paths_after_the_fixed_network_boundary(self):
for value in [b"///u@h", b"////u@h"]:
with self.subTest(value=value):
text, sidecar, redactions = location(value, b"file")
self.assertEqual(text, value.decode("ascii"))
self.assertEqual(sidecar["state"], "retained")
self.assertIsNotNone(sidecar["content_base64"])
self.assertEqual(redactions, [])
def test_file_urls_keep_path_text(self):
self.assertEqual(capture.without_userinfo("file:///a@b"), "file:///a@b")