From b9e72b9645765b364f1b6d64d291ab1e979c3fcf Mon Sep 17 00:00:00 2001 From: GOGOsu Date: Sat, 30 Apr 2022 05:56:10 +0800 Subject: [PATCH 01/14] Update aliyun-sms.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aliyun-sms.js: escape more characters than encodeURIComponent see https://help.aliyun.com/document_detail/315526.html 字符A~Z、a~z、0~9以及字符-、_、.、~不编码。对其它ASCII码字符进行编码。 --- server/notification-providers/aliyun-sms.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index fc281511..325d2214 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -92,9 +92,20 @@ class AliyunSMS extends NotificationProvider { let key = oa[i]; param2[key] = param[key]; } + + let moreEscapesTable = function(m) { + return { + "!": "%21", + "*": "%2A", + "'": "%27", + "(": "%28", + ")": "%29" + }[m] + }; for (let key in param2) { - data.push(`${encodeURIComponent(key)}=${encodeURIComponent(param2[key])}`); + let value = encodeURIComponent(param2[key]).replace(/[!*'()]/g, moreEscapesTable); + data.push(`${encodeURIComponent(key)}=${value}`); } let StringToSign = `POST&${encodeURIComponent("/")}&${encodeURIComponent(data.join("&"))}`; From ae2c49a72904aed503959b4cf7b595b53c5b4bab Mon Sep 17 00:00:00 2001 From: GOGOsu Date: Sat, 30 Apr 2022 06:28:16 +0800 Subject: [PATCH 02/14] Update aliyun-sms.js --- server/notification-providers/aliyun-sms.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index 325d2214..65843ebe 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -92,15 +92,15 @@ class AliyunSMS extends NotificationProvider { let key = oa[i]; param2[key] = param[key]; } - - let moreEscapesTable = function(m) { + + let moreEscapesTable = function (m) { return { - "!": "%21", - "*": "%2A", - "'": "%27", - "(": "%28", + "!": "%21", + "*": "%2A", + "'": "%27", + "(": "%28", ")": "%29" - }[m] + }[m]; }; for (let key in param2) { From 2347a01f7c6e0362c4c92081836c930d202dd9ff Mon Sep 17 00:00:00 2001 From: GOGOsu Date: Sat, 30 Apr 2022 10:42:59 +0800 Subject: [PATCH 03/14] Update aliyun-sms.js Add comments for the changed code. --- server/notification-providers/aliyun-sms.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index 65843ebe..11575df3 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -92,6 +92,10 @@ class AliyunSMS extends NotificationProvider { let key = oa[i]; param2[key] = param[key]; } + + // Escape more characters than encodeURIComponent does. + // For generating Aliyun signature, all characters except A-Za-z0-9~-._ are encoded. + // See https://help.aliyun.com/document_detail/315526.html let moreEscapesTable = function (m) { return { From 369477b4b920e14b177b1ab9f2779d1a58aa4d86 Mon Sep 17 00:00:00 2001 From: GOGOsu Date: Sat, 30 Apr 2022 10:45:38 +0800 Subject: [PATCH 04/14] Update aliyun-sms.js --- server/notification-providers/aliyun-sms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index 11575df3..2574cd3c 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -92,7 +92,7 @@ class AliyunSMS extends NotificationProvider { let key = oa[i]; param2[key] = param[key]; } - + // Escape more characters than encodeURIComponent does. // For generating Aliyun signature, all characters except A-Za-z0-9~-._ are encoded. // See https://help.aliyun.com/document_detail/315526.html From 73e38a13d2e1bf19c64edd063fb77fe323f6aa9b Mon Sep 17 00:00:00 2001 From: GOGOsu Date: Sat, 30 Apr 2022 21:08:35 +0800 Subject: [PATCH 05/14] Update server/notification-providers/aliyun-sms.js Co-authored-by: Adam Stachowicz --- server/notification-providers/aliyun-sms.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index 2574cd3c..79f0dd30 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -96,7 +96,6 @@ class AliyunSMS extends NotificationProvider { // Escape more characters than encodeURIComponent does. // For generating Aliyun signature, all characters except A-Za-z0-9~-._ are encoded. // See https://help.aliyun.com/document_detail/315526.html - let moreEscapesTable = function (m) { return { "!": "%21", From db50ba91cc12e63341fdfc9eb06d6131dd75c4f0 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 30 Apr 2022 21:44:03 +0800 Subject: [PATCH 06/14] Fix #1593 --- src/pages/EditMonitor.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 39c114ad..43f34527 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -421,7 +421,7 @@ export default { }, pushURL() { - return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?status=true&msg=OK&ping="; + return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?status=up&msg=OK&ping="; }, bodyPlaceholder() { From 272956025cb6b323c1d214bac85c7f2b5a0ede09 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Sun, 1 May 2022 05:18:08 +0800 Subject: [PATCH 07/14] Fix: Fix chart error on switch back to recent --- src/components/PingChart.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index d4f94a19..eb907e2d 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -218,7 +218,6 @@ export default { // Update chart data when the selected chart period changes chartPeriodHrs: function (newPeriod) { if (newPeriod === "0") { - newPeriod = null; this.heartbeatList = null; this.$root.storage().removeItem(`chart-period-${this.monitorId}`); } else { @@ -241,7 +240,7 @@ export default { // And mirror latest change to this.heartbeatList this.$watch(() => this.$root.heartbeatList[this.monitorId], (heartbeatList) => { - if (this.chartPeriodHrs !== 0) { + if (this.chartPeriodHrs !== "0") { const newBeat = heartbeatList.at(-1); if (newBeat && dayjs.utc(newBeat.time) > dayjs.utc(this.heartbeatList.at(-1)?.time)) { this.heartbeatList.push(heartbeatList.at(-1)); From 53b98ad3e488611bc426547c9de271411e6942b7 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 12:10:47 +0800 Subject: [PATCH 08/14] Add more comment for aliyun-sms fix --- server/notification-providers/aliyun-sms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index 79f0dd30..fa73ffb1 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -96,6 +96,7 @@ class AliyunSMS extends NotificationProvider { // Escape more characters than encodeURIComponent does. // For generating Aliyun signature, all characters except A-Za-z0-9~-._ are encoded. // See https://help.aliyun.com/document_detail/315526.html + // This encoding methods as known as RFC 3986 (https://tools.ietf.org/html/rfc3986) let moreEscapesTable = function (m) { return { "!": "%21", From 254a6bfd36a065475a0ab44a37cb511f0409df78 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 12:23:28 +0800 Subject: [PATCH 09/14] [CI] Run check linters first --- .github/workflows/auto-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index c0efc64a..1b6a8e04 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -11,6 +11,7 @@ on: jobs: auto-test: + needs: [ check-linters ] runs-on: ${{ matrix.os }} strategy: From 63c8d24d6f2322121f50628a26e652605aef5c86 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 12:32:06 +0800 Subject: [PATCH 10/14] As legacy-peer-deps is specified in .npmrc, `install-legacy` and `update-legacy` are not actually needed. --- .github/workflows/auto-test.yml | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 1b6a8e04..82451f37 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -29,7 +29,7 @@ jobs: with: node-version: ${{ matrix.node }} cache: 'npm' - - run: npm run install-legacy + - run: npm install - run: npm run build - run: npm test env: @@ -47,5 +47,5 @@ jobs: with: node-version: 16 cache: 'npm' - - run: npm run install-legacy + - run: npm install - run: npm run lint diff --git a/package.json b/package.json index 06c2a671..6b21096b 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "node": "14.* || >=16.*" }, "scripts": { - "install-legacy": "npm install --legacy-peer-deps", - "update-legacy": "npm update --legacy-peer-deps", + "install-legacy": "npm install", + "update-legacy": "npm update", "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .", "lint-fix:js": "eslint --ext \".js,.vue\" --fix --ignore-path .gitignore .", "lint:style": "stylelint \"**/*.{vue,css,scss}\" --ignore-path .gitignore", From 02a8147f22c7200f5f2d35e2c29f6dcc55084831 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 17:31:58 +0800 Subject: [PATCH 11/14] Remove undefined variable forceShowContent --- src/layouts/Layout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 7f9598bf..c7076221 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -71,7 +71,7 @@
- +
From 410805052e48776dd83bf3973619e38f61030c35 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 17:46:43 +0800 Subject: [PATCH 12/14] Log this.chartPeriodHrs --- src/components/PingChart.vue | 5 ++++- src/util.js | 2 +- src/util.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index eb907e2d..b35d999c 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -24,7 +24,7 @@ import timezone from "dayjs/plugin/timezone"; import utc from "dayjs/plugin/utc"; import { LineChart } from "vue-chart-3"; import { useToast } from "vue-toastification"; -import { DOWN } from "../util.ts"; +import { DOWN, log } from "../util.ts"; dayjs.extend(utc); dayjs.extend(timezone); @@ -240,6 +240,9 @@ export default { // And mirror latest change to this.heartbeatList this.$watch(() => this.$root.heartbeatList[this.monitorId], (heartbeatList) => { + + log.debug("ping_chart", `this.chartPeriodHrs type ${typeof this.chartPeriodHrs}, value: ${this.chartPeriodHrs}`); + if (this.chartPeriodHrs !== "0") { const newBeat = heartbeatList.at(-1); if (newBeat && dayjs.utc(newBeat.time) > dayjs.utc(this.heartbeatList.at(-1)?.time)) { diff --git a/src/util.js b/src/util.js index b1f55201..ee6095e0 100644 --- a/src/util.js +++ b/src/util.js @@ -102,7 +102,7 @@ class Logger { } else if (level === "DEBUG") { if (exports.isDev) { - console.debug(formattedMessage); + console.log(formattedMessage); } } else { diff --git a/src/util.ts b/src/util.ts index 75abd662..057090b7 100644 --- a/src/util.ts +++ b/src/util.ts @@ -113,7 +113,7 @@ class Logger { console.error(formattedMessage); } else if (level === "DEBUG") { if (isDev) { - console.debug(formattedMessage); + console.log(formattedMessage); } } else { console.log(formattedMessage); From a12dffd1bc6bb9955f1d66ab1f9c1d269c051bb5 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 17:56:42 +0800 Subject: [PATCH 13/14] Fallback to eqeq for PingChart.vue --- src/components/PingChart.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index b35d999c..67bdc00c 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -217,7 +217,9 @@ export default { watch: { // Update chart data when the selected chart period changes chartPeriodHrs: function (newPeriod) { - if (newPeriod === "0") { + + // eslint-disable-next-line eqeqeq + if (newPeriod == "0") { this.heartbeatList = null; this.$root.storage().removeItem(`chart-period-${this.monitorId}`); } else { @@ -243,7 +245,8 @@ export default { log.debug("ping_chart", `this.chartPeriodHrs type ${typeof this.chartPeriodHrs}, value: ${this.chartPeriodHrs}`); - if (this.chartPeriodHrs !== "0") { + // eslint-disable-next-line eqeqeq + if (this.chartPeriodHrs != "0") { const newBeat = heartbeatList.at(-1); if (newBeat && dayjs.utc(newBeat.time) > dayjs.utc(this.heartbeatList.at(-1)?.time)) { this.heartbeatList.push(heartbeatList.at(-1)); From 000cbeb0ce1921f36314ea904fcf5b23e61bd179 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 May 2022 18:25:52 +0800 Subject: [PATCH 14/14] Lower check-linters node version to 14, add Node.js 18, set timeout 15mins for each job --- .github/workflows/auto-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index 82451f37..a7a01684 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -13,11 +13,12 @@ jobs: auto-test: needs: [ check-linters ] runs-on: ${{ matrix.os }} + timeout-minutes: 15 strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - node: [14, 16, 17] + node: [ 14, 16, 17, 18 ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -45,7 +46,7 @@ jobs: - name: Use Node.js LTS uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 14 cache: 'npm' - run: npm install - run: npm run lint