Commit a11677f
Fix #160: Anchor IsJSON regex to prevent false positives on CDATA
The IsJSON() function was using an unanchored regex `\s*[{\[]` which
would match a `[` character anywhere in the input. This caused XML
documents containing CDATA sections like `<![CDATA[text]]>` to be
incorrectly detected as JSON.
Changed the regex to `^\s*[{\[]` to anchor it to the start of the
input string. Now only inputs that actually begin with `{` or `[`
(after optional whitespace) will be detected as JSON.
Added TestFormatDetection to verify CDATA sections are correctly
detected as XML format, not JSON format.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 727399c commit a11677f
2 files changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
522 | | - | |
| 522 | + | |
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| |||
0 commit comments