From 18539944944b9ddb5b5e072b169803b8e5f0aa43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=AD=E6=97=AD?= Date: Tue, 18 Apr 2023 14:11:09 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-91727=20=E5=AF=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=9A=84=E5=8F=82=E6=95=B0=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=A0=A1=E9=AA=8C=20DCM=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E6=94=B9=E4=B8=8B=20feat=EF=BC=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E9=80=BB=E8=BE=91=E5=8F=98=E6=9B=B4=EF=BC=8C=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E5=85=B3=E9=94=AE=E5=AD=97=E6=A0=A1=E9=AA=8C=E4=B8=8D?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkIllegalStrings.ts | 26 ++++++++++++------- .../core/checkIllegalStrings/constant.ts | 8 +++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts b/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts index 696d8fb..ddc4f99 100644 --- a/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts +++ b/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts @@ -18,19 +18,27 @@ export const CHECK_CORRECT: CheckResult = { export function checkIllegalStrings(value: string): CheckResult { // 后端传入的校验开关,如果没传,那也默认开启 const enabled = Dec.system.enableParameterVerify ?? true; + let result = CHECK_CORRECT; if (enabled) { - const illegalStringIndex = ILLEGAL_STRINGS.findIndex(s => value.includes(s)); - if (illegalStringIndex === -1) { - return CHECK_CORRECT; - } + // 关键字不区分大小写 + ILLEGAL_STRINGS.every(s => { + const sIndex = value.toLowerCase().indexOf(s); + if (sIndex !== -1) { + result = { + legal: false, + errorMsg: `${BI.i18nText("Dec-Basic_Check_Illegal_Strings")}${value.substr(sIndex, s.length)}`, + }; - return { - legal: false, - errorMsg: `${BI.i18nText("Dec-Basic_Check_Illegal_Strings")}${ILLEGAL_STRINGS[illegalStringIndex]}`, - }; + return false; + } + + return true; + }); + + return result; } - return CHECK_CORRECT; + return result; } export function checkIllegalStringsInWidgetAndShowError(widget: any) { diff --git a/src/modules/core/checkIllegalStrings/constant.ts b/src/modules/core/checkIllegalStrings/constant.ts index a034a3f..351c185 100644 --- a/src/modules/core/checkIllegalStrings/constant.ts +++ b/src/modules/core/checkIllegalStrings/constant.ts @@ -1,5 +1,5 @@ /** - * 参数检验的非法字符数组 + * 参数检验的非法字符数组,由于不区分大小写,统一用小写 */ export const ILLEGAL_STRINGS = [ "\"", @@ -9,7 +9,7 @@ export const ILLEGAL_STRINGS = [ "/script", "javascript:", "onblur", - "getRuntime", - "ProcessBuilder", - "java.lang.ProcessImpl", + "getruntime", + "processbuilder", + "java.lang.processimpl", ];