Fixed the regular expression to match the extra note in the summary for security, as suggested by SonarQube.

This commit is contained in:
依瑪貓 2023-03-08 21:28:10 +08:00
parent ffe834bedd
commit 4273f99644

View File

@ -763,7 +763,7 @@ class GeneralTripTab extends TagTabPlane {
* @override * @override
*/ */
populate() { populate() {
const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:[*×]\d+)?(?:\([^)]+\))?$/); const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/);
if (found === null) { if (found === null) {
return false; return false;
} }
@ -956,7 +956,7 @@ class BusTripTab extends TagTabPlane {
* @override * @override
*/ */
populate() { populate() {
const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:[*×]\d+)?(?:\([^)]+\))?$/); const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/);
if (found === null) { if (found === null) {
return false; return false;
} }
@ -1141,7 +1141,7 @@ class AnnotationTab extends TabPlane {
* @override * @override
*/ */
updateSummary() { updateSummary() {
const found = this.editor.summary.value.match(/^(.*?)(?:[*×]\d+)?(?:\([^)]+\))?$/); const found = this.editor.summary.value.match(/^(.*?)(?:[*×]\d+)?(?:\([^()]+\))?$/);
if (found !== null) { if (found !== null) {
this.editor.summary.value = found[1]; this.editor.summary.value = found[1];
} }
@ -1170,7 +1170,7 @@ class AnnotationTab extends TabPlane {
* @override * @override
*/ */
populate() { populate() {
const found = this.editor.summary.value.match(/^(.*?)(?:[*×](\d+))?(?:\(([^)]+)\))?$/); const found = this.editor.summary.value.match(/^(.*?)(?:[*×](\d+))?(?:\(([^()]+)\))?$/);
this.editor.summary.value = found[1]; this.editor.summary.value = found[1];
if (found[2] === undefined || parseInt(found[2]) === 1) { if (found[2] === undefined || parseInt(found[2]) === 1) {
this.editor.number.value = ""; this.editor.number.value = "";