mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-26 01:34:51 +08:00
normalizeTomlText replaced every curly/fullwidth quote in the text before TOML parsing, including quotes inside already-valid strings. MCP import and validation (tomlUtils, mcpDraft) and the Codex config editor therefore silently rewrote values such as args = ["don’t"] to "don't", and rejected valid configs like args = ["say“hello”"] or args = ['don’t'] because the inner quotes became delimiters. Scan the text instead: smart quotes outside strings are delimiters and become ASCII; strings opened by an ASCII quote keep smart quotes as content; strings opened by a smart quote may close with either form; multi-line strings and comments are handled. To keep the Chinese IME case working (the editor normalizes each keystroke, so the left quote is already ASCII when the right smart quote is typed), an ASCII-opened string left unterminated at end of line is re-scanned with smart closers, and if the strict result still fails to parse, a lenient scan is used only when it parses. Escaped smart double quotes in basic strings become \". Text without smart quotes is returned unchanged. Refs #8559