mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 00:02:51 +08:00
feat: 只处理 'formatter' key 为函数结构,防止错误字段解析
This commit is contained in:
parent
2201c09219
commit
0a12357997
@ -324,13 +324,17 @@ export const evalFn = (fn: string) => {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export const JSONParse = (data: string) => {
|
export const JSONParse = (data: string) => {
|
||||||
|
if (data.trim() === '') return
|
||||||
return JSON.parse(data, (k, v) => {
|
return JSON.parse(data, (k, v) => {
|
||||||
// 过滤函数字符串
|
// // 过滤函数字符串
|
||||||
if (excludeParseEventKeyList.includes(k)) return v
|
// if (excludeParseEventKeyList.includes(k)) return v
|
||||||
// 过滤函数值表达式
|
// // 过滤函数值表达式
|
||||||
if (typeof v === 'string') {
|
// if (typeof v === 'string') {
|
||||||
const someValue = excludeParseEventValueList.some(excludeValue => v.indexOf(excludeValue) > -1)
|
// const someValue = excludeParseEventValueList.some(excludeValue => v.indexOf(excludeValue) > -1)
|
||||||
if (someValue) return v
|
// if (someValue) return v
|
||||||
|
// }
|
||||||
|
if (k !== 'formatter') {
|
||||||
|
return v
|
||||||
}
|
}
|
||||||
// 还原函数值
|
// 还原函数值
|
||||||
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
|
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user