From 4d5d1f5daa332cbffc9e3bcdc6a159d2ac8d0ec2 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:02:00 +0800 Subject: [PATCH] fix(capture): preserve file-relative path evidence after separators --- bridge/mitmproxy/capture.py | 2 ++ bridge/mitmproxy/test_capture.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/bridge/mitmproxy/capture.py b/bridge/mitmproxy/capture.py index 678391ff8..b1e05e9f5 100644 --- a/bridge/mitmproxy/capture.py +++ b/bridge/mitmproxy/capture.py @@ -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 diff --git a/bridge/mitmproxy/test_capture.py b/bridge/mitmproxy/test_capture.py index 528553046..33732db07 100644 --- a/bridge/mitmproxy/test_capture.py +++ b/bridge/mitmproxy/test_capture.py @@ -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")