log_sanitizer: extend the URL-query stop-set with > and backtick, and pin the accepted fragment/space edges

Author: LearningCircuitCreated Sep 17, 2026Updated Sep 28, 2026
Labelspriority: lowpythontestsseverity:nitfrom-review-extractionfollow-up-work-in-progress

Summary

The query stop-set [^\s)\]\}\"'] in _URL_QUERY_STRING_RE does not stop at > or backtick, so a markdown autolink <https://h/p?q=1> scrubs to <https://h/p?<redacted> (closing > consumed) and a code span loses its closing backtick — the same wrapper-truncation class the stop-set exists to prevent. Fail-closed (over-redaction only), but it corrupts exactly the prose/log contexts the pattern's comment cites. Separately, two accepted edge behaviours documented in that comment (a fragment being swallowed into the redaction; a raw unencoded space truncating the match) have no pinning tests, so a future stop-set tweak can silently change them.

Field Value
Severity nit
Origin Review of #6422 (post-merge extraction)
Review section Nits
Classification PR-introduced
Verified at main@caf15bdf2617
Dedup distinct · 29 hits reviewed

Trigger

At main@caf15bdf2617, _redact_url_query_strings on the merged pattern outputs:

  • <https://h/p?q=1> → <https://h/p?<redacted> — the closing > is consumed by the redaction
  • `https://h/p?q=1` → `https://h/p?<redacted> — the closing backtick is consumed
  • control: see (https://h/p?q=1) end → see (https://h/p?<redacted>) end — ) is in the stop-set and survives
  • https://h/p?q=1#section → https://h/p?<redacted> — fragment swallowed (documented accepted edge, unpinned)
  • try https://h/p? yes untouched — the + quantifier fix from the review works

Impact

Cosmetic-to-diagnostic: markdown contexts in scrubbed log prose render broken after redaction, and the unpinned accepted edges can drift silently on the next stop-set edit. No leak — the failure mode is over-redaction, never exposure.

Pinned evidence

  • caf15bdf2617:src/local_deep_research/security/log_sanitizer.py:L309-L320 — stop-set [^\s)\]\}\"'] without > or backtick; the comment documents the wrapper-preservation intent and edge semantics
  • caf15bdf2617:tests/security/test_log_sanitizer.py:L603-L612 — paren and quote wrappers are pinned (test_markdown_link_closing_paren_survives, test_quoted_url_closing_quote_survives); no autolink, code-span, fragment, or raw-space counterparts exist in the file

Fix direction

Extend the stop-set to also stop at > and backtick, and add one pinning test per shape next to the existing paren/quote tests: markdown autolink <...>, code span, fragment q=1#section → ?<redacted>, and the raw-unencoded-space truncation edge.

Targeted tests

  • scrub_error(Exception("<https://h/p?q=1>")) keeps the closing >
  • a code-span URL keeps its closing backtick
  • fragment-swallow and raw-space-truncation asserted as accepted behaviour (regression guards against silent stop-set drift)

Provenance

Extracted from review of PR #6422 (post-merge extraction). Related: #6352.

Source: LearningCircuit/local-deep-research