From 163ac568b0efcf19fa03fba96479326b4c084fab Mon Sep 17 00:00:00 2001 From: Aaron Liang <76561968+AaronL725@users.noreply.github.com> Date: Tue, 14 Jul 2026 21:43:37 +0800 Subject: [PATCH] fix: repair audit patch escape preprocessor --- tools/fix_audit_patch_escapes.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/fix_audit_patch_escapes.py diff --git a/tools/fix_audit_patch_escapes.py b/tools/fix_audit_patch_escapes.py new file mode 100644 index 0000000..8a9e536 --- /dev/null +++ b/tools/fix_audit_patch_escapes.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +"""Repair string escapes inside the temporary audit patch script before running it. + +The patch script embeds Python source inside triple-quoted strings. Source snippets +that should generate literal backslash-n in grok_register_ttk.py must therefore +use double escaping in this script. +""" +from pathlib import Path + +path = Path(__file__).resolve().parent / "apply_audit_fixes.py" +text = path.read_text(encoding="utf-8") + +replacements = { + 'f.write("\\n")': 'f.write("\\\\n")', + 'line = f"{email}----{password or \'\'}----{sso}\\n"': 'line = f"{email}----{password or \'\'}----{sso}\\\\n"', +} + +for old, new in replacements.items(): + text = text.replace(old, new) + +path.write_text(text, encoding="utf-8") +print("audit patch escapes repaired")