fix(codex): backslash parity in the TOML closing-quote scan

Round 2's escape check rejected a quote whenever a single backslash
preceded it, so an escaped backslash before a real closing quote (e.g.
path = "path\\" # c) was misread as an escaped quote and the field was
dropped. Now counts the run of backslashes and only treats an ODD run as
escaping the quote. Folded the old two-branch quote handling into one
scan (it already finds the terminator correctly with or without a
trailing comment) and decode \\ -> \ in the extracted value, since the
scan already knows which backslash run is real.
This commit is contained in:
2026-09-08 16:57:02 +07:00
parent 236e94760f
commit b0788eea80
2 changed files with 23 additions and 12 deletions
+10
View File
@@ -98,6 +98,16 @@ describe("codex-discovery", () => {
assert.equal(meta.description, 'say \\"hi\\"');
});
it("recognises a quote preceded by an escaped backslash as a real terminator", () => {
const meta = cx.readTomlMeta('path = "path\\\\" # c\n');
assert.equal(meta.path, "path\\");
});
it("keeps counting backslash pairs correctly with four of them before the terminator", () => {
const meta = cx.readTomlMeta('key = "a\\\\\\\\" # c\n');
assert.equal(meta.key, "a\\\\");
});
it("reads a rule file's preview", () => {
write(
path.join(TMP, "rules", "no-force-push.rules"),