mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-08-31 01:46:49 +00:00
Strip encoded attachment metadata delimiters
This commit is contained in:
parent
e9d5274064
commit
efdb5f4aca
2 changed files with 10 additions and 0 deletions
|
|
@ -88,6 +88,7 @@ def _attachment_log_metadata(attachments: list[str]) -> dict[str, list[str]]:
|
|||
continue
|
||||
path = parsed.path if parsed.scheme else normalized.split("?", 1)[0].split("#", 1)[0]
|
||||
path = unquote(path).replace("\\", "/")
|
||||
path = path.split("?", 1)[0].split("#", 1)[0]
|
||||
if path.endswith("/"):
|
||||
continue
|
||||
name = path.rstrip("/").rsplit("/", 1)[-1]
|
||||
|
|
|
|||
|
|
@ -43,6 +43,15 @@ def test_attachment_log_metadata_decodes_encoded_separators() -> None:
|
|||
) == {"attachments": ["secret.png", "secret.png"]}
|
||||
|
||||
|
||||
def test_attachment_log_metadata_strips_encoded_query_and_fragment_suffixes() -> None:
|
||||
assert _attachment_log_metadata(
|
||||
[
|
||||
"https://host/report%3Ftoken%3Dsecret.png",
|
||||
"https://host/image%23private-fragment.png",
|
||||
]
|
||||
) == {"attachments": ["report", "image"]}
|
||||
|
||||
|
||||
class RecordingLog:
|
||||
def __init__(self) -> None:
|
||||
self.calls: list[dict[str, object]] = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue