From 535ff96ab38385d01c921fffce7bf4925d122b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 28 Feb 2023 23:53:56 +0800 Subject: [PATCH] Revised the JavaScript regular expressions used in the summary helper, as suggested by SonarQube for security. --- src/accounting/static/js/summary-helper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/accounting/static/js/summary-helper.js b/src/accounting/static/js/summary-helper.js index 646adb0..407fd75 100644 --- a/src/accounting/static/js/summary-helper.js +++ b/src/accounting/static/js/summary-helper.js @@ -698,15 +698,15 @@ class SummaryHelper { return; } let found; - found = summary.value.match(/^(.+?)—(.+?)—(.+?)→(.+?)(?:×(\d+)?)?$/); + found = summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:×(\d+))?$/); if (found !== null) { return this.#populateBusTrip(found[1], found[2], found[3], found[4], found[5]); } - found = summary.value.match(/^(.+?)—(.+?)([→↔])(.+?)(?:×(\d+)?)?$/); + found = summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:×(\d+))?$/); if (found !== null) { return this.#populateGeneralTrip(found[1], found[2], found[3], found[4], found[5]); } - found = summary.value.match(/^(.+?)—.+?(?:×(\d+)?)?$/); + found = summary.value.match(/^([^—]+)—.+?(?:×(\d+)?)?$/); if (found !== null) { return this.#populateGeneralTag(found[1], found[2]); }