Revised the JavaScript regular expressions used in the summary helper, as suggested by SonarQube for security.

This commit is contained in:
依瑪貓 2023-02-28 23:53:56 +08:00
parent 57482f81fc
commit 535ff96ab3

View File

@ -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]);
}