mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
fix(decision): replace fullwidth space (U+3000) in JSON
Critical bug: AI can output fullwidth space ( U+3000) between brackets:
Input: [ {"symbol":"BTCUSDT"}]
↑ ↑ fullwidth space
After previous fix:
[ {"symbol":"BTCUSDT"}]
↑ fullwidth space remained!
Result: validateJSONFormat failed because:
- Checks "[{" (no space) ❌
- Checks "[ {" (halfwidth space U+0020) ❌
- AI output "[ {" (fullwidth space U+3000) ❌
Solution: Replace fullwidth space → halfwidth space
- (U+3000) → space (U+0020)
This allows existing validation logic to work:
strings.HasPrefix(trimmed, "[ {") now matches ✅
Why fullwidth space?
- Common in CJK text editing
- AI trained on mixed CJK content
- Invisible to naked eye but breaks JSON parsing
Test case:
Input: [ {"symbol":"BTCUSDT"}]
Output: [ {"symbol":"BTCUSDT"}]
Validation: ✅ PASS
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -487,6 +487,9 @@ func fixMissingQuotes(jsonStr string) string {
|
||||
jsonStr = strings.ReplaceAll(jsonStr, "〕", "]") // CJK右龟壳括号 U+3015
|
||||
jsonStr = strings.ReplaceAll(jsonStr, "、", ",") // CJK顿号 U+3001
|
||||
|
||||
// ⚠️ 替换全角空格为半角空格(JSON中不应该有全角空格)
|
||||
jsonStr = strings.ReplaceAll(jsonStr, " ", " ") // U+3000 全角空格
|
||||
|
||||
return jsonStr
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user