From 4bab919446a1318c73d56fd1b725d83317d2d1c8 Mon Sep 17 00:00:00 2001 From: kshitij Date: Thu, 6 Aug 2026 03:56:06 +0530 Subject: [PATCH] refactor(sessions): use _escape_like in _cwd_prefix_clause Follow-up on the salvage of #78681 + #78927: the second fix inlined the exact body of the _escape_like helper the first fix introduced ten lines above. Call the helper instead so there is one copy of the escaping rule. --- hermes_state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes_state.py b/hermes_state.py index 948f30e35e2f7..8d51a39507153 100644 --- a/hermes_state.py +++ b/hermes_state.py @@ -194,7 +194,7 @@ def _cwd_prefix_clause(cwd_prefix: str) -> Tuple[str, List[str]]: # Escape the needle and pair it with ESCAPE; the literal separator # backslash in the Windows pattern needs escaping for the same reason. The # ``=`` arm is an exact compare and keeps the raw prefix. - esc = prefix.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_") + esc = _escape_like(prefix) return ( "(s.cwd = ? OR s.cwd LIKE ? ESCAPE '\\' OR s.cwd LIKE ? ESCAPE '\\')", [prefix, f"{esc}/%", f"{esc}\\\\%"],