From 0abea4bcefb4e0b8a5039ee8ae4e2141a257a328 Mon Sep 17 00:00:00 2001 From: gordlin Date: Fri, 21 Feb 2025 10:48:23 -0500 Subject: [PATCH] Prevent addition of illegal characters to new/renamed UUIDs --- src/components/metadata-editor.vue | 18 ++++++++++++++++-- src/lang/lang.csv | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/metadata-editor.vue b/src/components/metadata-editor.vue index 59eebfff2..f430782f5 100644 --- a/src/components/metadata-editor.vue +++ b/src/components/metadata-editor.vue @@ -107,6 +107,7 @@ changeUuid.length === 0 || checkingUuid || processingRename || + error || warning === 'rename' " > @@ -237,7 +238,7 @@ > { if (rename || !this.loadExisting) this.checkingUuid = true; + + if (!this.loadExisting || rename) { + // All reserved characters in URLs. The user can't use these for their UUID + const illegalChars = [':', '/', '#', '?', '&', '@', '%', '+']; + const illegalCharsContained = illegalChars.filter(badChar => (rename ? this.changeUuid : this.uuid).includes(badChar)); + + if (illegalCharsContained.length) { + this.error = true; + this.warning = 'badChar'; + this.checkingUuid = false; + return; + } + if (!rename && !this.uuid) { if (!this.loadExisting) { this.error = true; diff --git a/src/lang/lang.csv b/src/lang/lang.csv index f798d2e6a..ea7290202 100644 --- a/src/lang/lang.csv +++ b/src/lang/lang.csv @@ -104,6 +104,7 @@ editor.metadata.newUuidInstructions,"Enter a unique ID for your new storyline. O editor.warning.rename,UUID already in use. Please choose a different ID.,1,UUID déjà utilisé. Veuillez choisir un autre identifiant.,0 editor.warning.blank,UUID field cannot be blank. Please enter a unique UUID.,1,Le champ UUID ne peut pas être vide. Veuillez saisir un UUID unique.,0 editor.warning.renameFailed,Failed to rename product.,1,Échec du renommage du produit.,0 +editor.warning.badChar,"Illegal character entered. You cannot use these characters in your UUID: {': / # ? & @ % +'}",1,"Caractère illégal saisi. Vous ne pouvez pas utiliser ces caractères dans votre UUID: {': / # ? & @ % +'}",0 editor.changeUuid,Click here to change UUID,1,Cliquez ici pour changer,0 editor.title,Title,1,Titre,1 editor.respectTitle,RAMP Storylines Editor & Creation Tool,1,Éditeur et outil de création de scénarios RAMP,0