Files
nofx/decision
ZhouYongyou 7e049cd8b4 fix(decision): correct regex pattern to avoid matching non-json code blocks
## Problem

Commit 63e31ae introduced a regex pattern that was too permissive:
```go
reJSONFence = regexp.MustCompile("(?is)```(?:json[a-z0-9_-]*)?\...")
```

This could match ANY code block (```text, ```js, etc.), not just JSON.

## Issues

1. **Wrong Match**: Could extract from non-JSON code blocks
2. **Escaping**: Triple backticks in double quotes may cause issues
3. **Too Loose**: Regex accepts ```, ```json, ```json5, etc.

## Fix

Revert to safe, precise regex:
```go
reJSONFence = regexp.MustCompile(`(?is)` + "```json\s*...")
```

-  Only matches ```json code blocks
-  Uses backticks + string concat to avoid escaping
-  Keeps performance optimization (precompiled)

## Testing

-  Compiles successfully
-  Regex patterns verified
-  No syntax errors

Related: #regex #json-extraction #bug-fix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 00:43:10 +08:00
..