mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: validate JSON object in form submission
This commit is contained in:
parent
f31a8d380a
commit
b60c471694
|
|
@ -246,7 +246,10 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
await formEl.validate((valid: any) => {
|
||||
if (valid) {
|
||||
try {
|
||||
JSON.parse(form.value.code as string)
|
||||
const parsed = JSON.parse(form.value.code as string)
|
||||
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
||||
throw new Error('Code must be a valid JSON object')
|
||||
}
|
||||
} catch (e) {
|
||||
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue