Merge branch 'cherry-pick-6f72b225' into 'dev-23.09'

fix: 修复实体搜索内容包含非英文时会弹窗提示非法字符串的问题

See merge request cyber-narrator/cn-ui!45
This commit is contained in:
陈劲松
2023-10-10 02:50:16 +00:00
4 changed files with 18 additions and 2 deletions

View File

@@ -624,6 +624,11 @@ export default {
const parser = new Parser(this.columnList) const parser = new Parser(this.columnList)
if (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1) { if (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1) {
q = decodeURI(q) q = decodeURI(q)
} else {
const str1 = q.substring(q.indexOf('%'), q.indexOf('%') + 3)
if (q.indexOf('%') > 0 && (str1 !== '%20' || str1 === '%25')) {
q = decodeURI(q)
}
} }
this.metaList = parser.parseStr(q).metaList this.metaList = parser.parseStr(q).metaList
} }

View File

@@ -225,6 +225,11 @@ export default {
if (q) { if (q) {
if (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1) { if (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1) {
q = decodeURI(q) q = decodeURI(q)
} else {
const str1 = q.substring(q.indexOf('%'), q.indexOf('%') + 3)
if (q.indexOf('%') > 0 && (str1 !== '%20' || str1 === '%25')) {
q = decodeURI(q)
}
} }
// 为避免地址栏任意输入导致全查询的q带QUERY解析时不识别导致的语法错误 // 为避免地址栏任意输入导致全查询的q带QUERY解析时不识别导致的语法错误
// 如地址栏输入116.178.222.171此时的q很长刷新界面时需要把q里的116.178.222.171拿出来进行搜索 // 如地址栏输入116.178.222.171此时的q很长刷新界面时需要把q里的116.178.222.171拿出来进行搜索

View File

@@ -6,9 +6,10 @@ import { ElMessage } from 'element-plus'
import i18n from '@/i18n' import i18n from '@/i18n'
const strReg = { const strReg = {
all: /^[\da-zA-Z\s.'><!=-_(),%]$/, // 需要不限制语言,正则过滤中英日语出错实现语言都通过。留个记录观察,后续校验
all: /^[\da-zA-Z\u4E00-\u9FA5\u0800-\u4e00\s.'><!=-_(),%]$/,
key: /^(?![\d])[\da-zA-Z\s.'-_]$/, key: /^(?![\d])[\da-zA-Z\s.'-_]$/,
value: /^[\da-zA-Z\s.'-_%]$/ value: /^[\da-zA-Z\u4E00-\u9FA5\u0800-\u4e00\s.'-_%]$/
} }
const operatorList = ['=', ' in ', ' IN ', ' like ', ' LIKE ', 'HAS(', 'has('] const operatorList = ['=', ' in ', ' IN ', ' like ', ' LIKE ', 'HAS(', 'has(']

View File

@@ -702,6 +702,11 @@ export default {
if (q && (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1)) { if (q && (q.indexOf('%') === 0 || q.indexOf('%20') > -1 || q.indexOf('%25') > -1)) {
q = decodeURI(q) q = decodeURI(q)
} }
// %位置不为0即内容包含非英文时
const str1 = q.substring(q.indexOf('%'), q.indexOf('%') + 3)
if (q && q.indexOf('%') > 0 && (str1 !== '%20' || str1 === '%25')) {
q = decodeURI(q)
}
this.initSearch(q) this.initSearch(q)
this.listMode = listMode this.listMode = listMode
} }