Skip to content

内部使用的co-body库的json校验出现造成代码错误 #225

@xiaolifeipiao

Description

@xiaolifeipiao

co-body库对json字符串的校验存在问题,是否考虑引用其他库替代

var strictJSONReg = /^[\x20\x09\x0a\x0d]*([|{)/;

function parse(str){
if (!strict) return str ? JSON.parse(str) : str;
// strict mode always return object
if (!str) return {};
// strict JSON test
if (!strictJSONReg.test(str)) {
throw new Error('invalid JSON, only supports object and array');
}
return JSON.parse(str);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions