fn repair_bare_backslashes(raw: &str) -> StringExpand description
Escape every backslash in raw unconditionally. Targets exactly the one
corruption shape seen in production — a raw Windows path (C:\Users\...)
pasted into a JSON string with NO escaping at all — so every backslash in
a still-unparseable row is a literal path separator, never an intentional
JSON escape (a document containing even one real \n/\t/\\ escape
alongside bare backslashes would imply two different corruption
mechanisms touched the same row, which has no evidence and isn’t
something this targeted repair needs to handle).
This is deliberately NOT a no-op on already-valid JSON — doubling a
genuine \\ pair would over-escape it. That’s fine because the only
caller (identity_repair_malformed_secret_refs) already checks
serde_json::from_str first and skips rows that parse cleanly; this
function must never be called on a value that isn’t already confirmed
invalid.
A prior version tried to distinguish “bare” backslashes from “already
valid escape sequences” by peeking at the next character (\b, \t,
\n, … look like valid escapes). That’s unsound for real Windows
paths: a segment like \bob\test starts with \b and \t, which are
themselves valid JSON escape shapes, so the heuristic left them
un-doubled and silently produced a backspace/tab character instead of
the literal path (caught by reagent review on PR #2419).