fix(toml): normalize CJK quotes to prevent parsing errors
Add quote normalization to handle Chinese/fullwidth quotes automatically
converted by IME. This fixes TOML parsing failures when users input
configuration with non-ASCII quotes (" " ' ' etc.).
Changes:
- Add textNormalization utility for quote normalization
- Apply normalization in TOML input handlers (MCP form, Codex config)
- Disable browser auto-correction in Textarea component
- Add defensive normalization in TOML parsing layer
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
extractCodexBaseUrl,
|
||||
setCodexBaseUrl as setCodexBaseUrlInConfig,
|
||||
} from "@/utils/providerConfigUtils";
|
||||
import { normalizeTomlText } from "@/utils/textNormalization";
|
||||
|
||||
interface UseCodexConfigStateProps {
|
||||
initialData?: {
|
||||
@@ -159,10 +160,12 @@ export function useCodexConfigState({ initialData }: UseCodexConfigStateProps) {
|
||||
// 处理 config 变化(同步 Base URL)
|
||||
const handleCodexConfigChange = useCallback(
|
||||
(value: string) => {
|
||||
setCodexConfig(value);
|
||||
// 归一化中文/全角/弯引号,避免 TOML 解析报错
|
||||
const normalized = normalizeTomlText(value);
|
||||
setCodexConfig(normalized);
|
||||
|
||||
if (!isUpdatingCodexBaseUrlRef.current) {
|
||||
const extracted = extractCodexBaseUrl(value) || "";
|
||||
const extracted = extractCodexBaseUrl(normalized) || "";
|
||||
if (extracted !== codexBaseUrl) {
|
||||
setCodexBaseUrl(extracted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user