From ff3e2fd5ebbb55737111a2881f7226b67a396e86 Mon Sep 17 00:00:00 2001 From: Ethan Hurst Date: Fri, 27 Feb 2026 18:58:55 +0000 Subject: [PATCH] fix: escape regex metacharacters in stateExtractField (#741) stateReplaceField properly escaped fieldName before building the regex, but stateExtractField did not. Field names containing regex metacharacters could cause incorrect matches or regex errors. Co-authored-by: Ethan Hurst --- get-shit-done/bin/lib/state.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/get-shit-done/bin/lib/state.cjs b/get-shit-done/bin/lib/state.cjs index 2916af9d5..915f51c45 100644 --- a/get-shit-done/bin/lib/state.cjs +++ b/get-shit-done/bin/lib/state.cjs @@ -151,7 +151,8 @@ function cmdStateUpdate(cwd, field, value) { // ─── State Progression Engine ──────────────────────────────────────────────── function stateExtractField(content, fieldName) { - const pattern = new RegExp(`\\*\\*${fieldName}:\\*\\*\\s*(.+)`, 'i'); + const escaped = fieldName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const pattern = new RegExp(`\\*\\*${escaped}:\\*\\*\\s*(.+)`, 'i'); const match = content.match(pattern); return match ? match[1].trim() : null; }