diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index bc3c76a86..c376a8b53 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -497,7 +497,7 @@ export default { const axiosArr = [] const paramStr = this.currentMsg ? JSON.stringify(this.promQueryParamConvert(this.currentMsg)) : null if (paramStr && paramStr.trim() != '""') { - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))) this.legend = [] this.chartDatas = [] axios.all(axiosArr).then(res => { @@ -991,7 +991,7 @@ export default { const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000) const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime()) this.expressions = [this.currentMsg.alertRule.expr] - this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { + this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { this.chartLoading = false const logData = [res.data] this.resultType = res.data.resultType diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index 33ad09b4f..0fd966648 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -734,7 +734,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = escape(filterItem.expression) + let query = encodeURIComponent(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -1227,7 +1227,7 @@ export default { const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') // const step = bus.getStep(startTime, endTime) this.$nextTick(() => { - let query = escape(chartInfo.elements[0].expression) + let query = encodeURIComponent(chartInfo.elements[0].expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea') && chartInfo.param) { chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 91dd9beb5..1262fe852 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -1004,7 +1004,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = escape(filterItem.expression) + let query = encodeURIComponent(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 00850d551..2a0d68bed 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -418,7 +418,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - const query = escape(filterItem.expression) + const query = encodeURIComponent(filterItem.expression) // if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){ // return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step); // } @@ -1662,7 +1662,7 @@ export default { const step = bus.getStep(startTime, endTime) axiosArr = this.chart.elements.map((ele) => { const filterItem = ele - const query = escape(filterItem.expression) + const query = encodeURIComponent(filterItem.expression) let str = '' if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null chartItem.param.nullType = chartItem.param.nullType || 'null' diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index a5440d477..9a0ebaaa4 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1645,7 +1645,7 @@ export default { if (type === 'list') { // 普通模式,主控台使用 axiosArr = this.data.elements.map((ele) => { const filterItem = ele - let query = escape(filterItem.expression) + let query = encodeURIComponent(filterItem.expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null !this.chartInfo.param && (this.chartInfo.param = {}) this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' @@ -1658,7 +1658,7 @@ export default { endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') this.data.elements.forEach((ele) => { const filterItem = ele - let query = escape(filterItem.expression) + let query = encodeURIComponent(filterItem.expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null !this.chartInfo.param && (this.chartInfo.param = {}) this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' @@ -1670,14 +1670,14 @@ export default { } else if (type === 'dashboard') { // 概览模式,指标概览中使用 // 概览模式,需要区分单独一个和多个 if (this.stableFilter.chartCount === 'multiple') { - let query = escape(this.data.name) + let query = encodeURIComponent(this.data.name) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType } axiosArr = [this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] } else { - let query = escape(this.data.elements[0].expression) + let query = encodeURIComponent(this.data.elements[0].expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType diff --git a/nezha-fronted/src/components/charts/logs.vue b/nezha-fronted/src/components/charts/logs.vue index 395093442..b7f9b03a0 100644 --- a/nezha-fronted/src/components/charts/logs.vue +++ b/nezha-fronted/src/components/charts/logs.vue @@ -333,7 +333,7 @@ export default { const requestArr = [] this.expressions.forEach((item, index) => { if (item != '' && this.from.trim() != fromRoute.chartTemp) { - requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.startTime) + '&end=' + this.$stringTimeParseToUnix(this.endTime) + '&limit=' + limit)) + requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.startTime) + '&end=' + this.$stringTimeParseToUnix(this.endTime) + '&limit=' + limit)) } else if (item != '' && this.from.trim() == fromRoute.chartTemp) { requestArr.push(logsTempData[index % 2]) } @@ -416,7 +416,7 @@ export default { const requestArr = [] this.expressions.forEach((item, index) => { if (item != '' && this.from.trim() != fromRoute.chartTemp) { - requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.searchTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.searchTime[1]) + '&limit=' + limit)) + requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.searchTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.searchTime[1]) + '&limit=' + limit)) } else if (item != '' && this.from.trim() == fromRoute.chartTemp) { requestArr.push(logsTempData[index % 2]) } diff --git a/nezha-fronted/src/components/cli/webSSH.vue b/nezha-fronted/src/components/cli/webSSH.vue index 42b3d2724..ed07f0e8c 100644 --- a/nezha-fronted/src/components/cli/webSSH.vue +++ b/nezha-fronted/src/components/cli/webSSH.vue @@ -555,13 +555,13 @@ export default { host: this.customConnect.host, port: this.customConnect.port, authType: this.customConnect.authType, - authUsername: encodeURIComponent(this.customConnect.authUsername), + authUsername: encodeURIComponentComponent(this.customConnect.authUsername), authPin: this.encode(this.customConnect.authPin), - authPriKey: encodeURIComponent(this.customConnect.authPriKey), - authUserTip: encodeURIComponent(this.customConnect.authUserTip), - authPinTip: encodeURIComponent(this.customConnect.authPinTip), - authProtocolPort: encodeURIComponent(this.customConnect.authProtocolPort), - authProtocol: encodeURIComponent(this.customConnect.authProtocol) + authPriKey: encodeURIComponentComponent(this.customConnect.authPriKey), + authUserTip: encodeURIComponentComponent(this.customConnect.authUserTip), + authPinTip: encodeURIComponentComponent(this.customConnect.authPinTip), + authProtocolPort: encodeURIComponentComponent(this.customConnect.authProtocolPort), + authProtocol: encodeURIComponentComponent(this.customConnect.authProtocol) } } this.editableTabsValue = newTabName @@ -995,7 +995,7 @@ export default { }, encode (str) { // 对编码的字符串转化base64 - const base64 = encodeURIComponent(btoa(str)) + const base64 = encodeURIComponentComponent(btoa(str)) return base64 }, closeAssetCustom () { diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 347f7aef6..ea6a8d5da 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -681,7 +681,7 @@ export default { resolve({ data: '', status: 'no query' }) }) } - query = escape(query) + query = encodeURIComponent(query) query += '&nullType=' + 'null' return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue index 734171757..9918cd9ee 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue @@ -264,7 +264,7 @@ export default { if (this.$refs.messageChart) { this.$refs.messageChart.startLoading() const axiosArr = [] - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))) this.legend = [] this.chartDatas = [] axios.all(axiosArr).then(res => { @@ -738,7 +738,7 @@ export default { const start = this.searchTime[0] ? this.searchTime[0] : getTime(-1, 'h') const end = this.searchTime[1] ? this.searchTime[1] : getTime(0, 'h') this.expressions = [this.currentMsg.alertRule.expr] - this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { + this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { this.chartLoading = false const logData = [res.data] this.resultType = res.data.resultType diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue index c1874ef75..f7e205288 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue @@ -250,7 +250,7 @@ export default { this.tableData = [] this.tableDataCopy = '' setTimeout(() => { - this.$get('/prom/api/v1/query?query=' + escape("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.formatTime).then(response => { + this.$get('/prom/api/v1/query?query=' + encodeURIComponent("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.formatTime).then(response => { this.loading = false if (response.status === 'success') { const results = response.data.result @@ -452,13 +452,13 @@ export default { } const axiosArr = [] for (const endpoint of this.selectedEndpoints) { - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) } if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') for (const endpoint of this.selectedEndpoints) { - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) } } this.legend = [] diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue index ab6f1b6da..2c5ed924e 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue @@ -115,7 +115,7 @@ export default { if (item != '') { let expr = item this.matchContent && (expr = `${item} ${this.matchSymbol} "${this.matchContent}"`) - requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(expr) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit)) + requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit)) } }) axios.all(requestArr).then(res => { diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 3366c2eda..889db0f6c 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -311,7 +311,7 @@ export default { }, downloadTxt () { const element = document.createElement('a') - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.fileContent)) + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponentComponent(this.fileContent)) element.setAttribute('download', 'Nezha recovery codes') element.style.display = 'none' element.click() diff --git a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue index 54d424123..2d47ecee1 100644 --- a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue +++ b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue @@ -137,7 +137,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = escape(filterItem.expression) + let query = encodeURIComponent(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 5190c56cc..62a2d637e 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -686,7 +686,7 @@ export default { resolve({ data: '', status: 'no query' }) }) } - query = escape(query) + query = encodeURIComponent(query) query += '&nullType=' + 'null' return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) diff --git a/nezha-fronted/src/components/common/table/special/endpointQueryTab.vue b/nezha-fronted/src/components/common/table/special/endpointQueryTab.vue index f8bc48286..7869d9b26 100644 --- a/nezha-fronted/src/components/common/table/special/endpointQueryTab.vue +++ b/nezha-fronted/src/components/common/table/special/endpointQueryTab.vue @@ -168,7 +168,7 @@ export default { this.tableData = [] this.tableDataCopy = '' setTimeout(() => { - this.$get('/prom/api/v1/query?query=' + escape("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.$stringTimeParseToUnix(new Date(this.formatTime).getTime())).then(response => { + this.$get('/prom/api/v1/query?query=' + encodeURIComponent("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.$stringTimeParseToUnix(new Date(this.formatTime).getTime())).then(response => { this.loading = false if (response.status === 'success') { const results = response.data.result @@ -378,13 +378,13 @@ export default { } const axiosArr = [] for (const endpoint of this.batchDeleteObjs) { - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) } if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') for (const endpoint of this.batchDeleteObjs) { - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) } } this.legend = [] diff --git a/nezha-fronted/src/components/common/v-selectpagenew/methods.js b/nezha-fronted/src/components/common/v-selectpagenew/methods.js index 85ad4bdf7..cf853517b 100644 --- a/nezha-fronted/src/components/common/v-selectpagenew/methods.js +++ b/nezha-fronted/src/components/common/v-selectpagenew/methods.js @@ -4,7 +4,7 @@ const RIGHT = 39 const DOWN = 40 const TAB = 9 const ENTER = 13 -const ESCAPE = 27 +const encodeURIComponent = 27 export default { methods: { @@ -82,10 +82,10 @@ export default { } }, processKey (e) { - if (![LEFT, UP, RIGHT, DOWN, ESCAPE, ENTER, TAB].includes(e.keyCode)) this.populate() + if (![LEFT, UP, RIGHT, DOWN, encodeURIComponent, ENTER, TAB].includes(e.keyCode)) this.populate() }, processControl (e) { - if ([LEFT, UP, RIGHT, DOWN, ESCAPE, ENTER, TAB].includes(e.keyCode)) { + if ([LEFT, UP, RIGHT, DOWN, encodeURIComponent, ENTER, TAB].includes(e.keyCode)) { switch (e.keyCode) { case LEFT: if (this.pagination) this.$refs.page.switchPage('previous') @@ -103,7 +103,7 @@ export default { case ENTER: if (this.highlight !== -1) this.selectItem(this.list[this.highlight]) break - case ESCAPE: + case encodeURIComponent: this.close() break } diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index 451cbacdf..df513863c 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -511,7 +511,7 @@ export default { if (this.$refs.messageChart) { this.$refs.messageChart.startLoading() const axiosArr = [] - axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))) this.legend = [] this.chartDatas = [] axios.all(axiosArr).then(res => { @@ -659,7 +659,7 @@ export default { const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000) const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime()) this.expressions = [this.currentMsg.alertRule.expr] - this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { + this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { this.chartLoading = false const logData = [res.data] this.resultType = res.data.resultType diff --git a/nezha-fronted/src/components/page/config/profile.vue b/nezha-fronted/src/components/page/config/profile.vue index ec47d2a63..df583e174 100644 --- a/nezha-fronted/src/components/page/config/profile.vue +++ b/nezha-fronted/src/components/page/config/profile.vue @@ -368,7 +368,7 @@ export default { }, downloadTxt () { const element = document.createElement('a') - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.fileContent)) + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponentComponent(this.fileContent)) element.setAttribute('download', 'Nezha recovery codes') element.style.display = 'none' element.click() diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue index 8100a8e18..0ec6f54c3 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue @@ -472,7 +472,7 @@ export default { const requestArr = [] this.expressions.forEach((item, index) => { if (item != '') { - requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit)) + requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit)) } }) if (requestArr.length > 0) { @@ -615,7 +615,7 @@ export default { const step = bus.getStep(this.filterTime[0], this.filterTime[1]) promqlInputIndexs.push(index) queryExpression.push(item) - requestArr.push(this.$get('/prom/api/v1/query_range?query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&step=' + step + '&nullType=null')) + requestArr.push(this.$get('/prom/api/v1/query_range?query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&step=' + step + '&nullType=null')) } }) if (requestArr.length > 0) { @@ -700,7 +700,7 @@ export default { const requestArr = [] this.expressions.forEach((item, index) => { if (item !== '') { - requestArr.push(this.$get('/prom/api/v1/query?query=' + escape(item))) + requestArr.push(this.$get('/prom/api/v1/query?query=' + encodeURIComponent(item))) } }) if (requestArr.length > 0) { diff --git a/nezha-fronted/src/components/page/dashboard/metricPreview.vue b/nezha-fronted/src/components/page/dashboard/metricPreview.vue index 432d28607..c60a7bbed 100644 --- a/nezha-fronted/src/components/page/dashboard/metricPreview.vue +++ b/nezha-fronted/src/components/page/dashboard/metricPreview.vue @@ -261,7 +261,7 @@ export default { this.filter.end_time = endTime const step = bus.getStep(startTime, endTime) const query = params.elements[0].expression - this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step).then(response => { + this.$get('/prom/api/v1/query_range?query=' + encodeURIComponent(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step).then(response => { this.$refs.metricSet.loading = false if (response.status === 'success') { if (response.data.result) {