Skip to content

Commit

Permalink
Merge pull request #556 from gordlin/uuid-illegal-chars
Browse files Browse the repository at this point in the history
Prevent addition of illegal characters to new/renamed UUIDs
  • Loading branch information
szczz authored Mar 6, 2025
2 parents 5b4a912 + 9bb4a97 commit 6a734cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
changeUuid.length === 0 ||
checkingUuid ||
processingRename ||
error ||
warning === 'rename'
"
>
Expand Down Expand Up @@ -225,7 +226,7 @@
>
<span
class="align-middle inline-block mr-1 fill-current"
:class="{ 'sm:ml-28': warning === 'rename' }"
:class="{ 'sm:ml-24': renameMode }"
>
<svg
clip-rule="evenodd"
Expand Down Expand Up @@ -650,7 +651,7 @@ export default class MetadataEditorV extends Vue {
loadingIntoEditor = false;
loadEditor = false;
error = false; // whether an error has occurred
warning: 'none' | 'uuid' | 'rename' | 'blank' | 'uuidNotFound' = 'none'; // used for duplicate uuid warning
warning: 'none' | 'uuid' | 'rename' | 'blank' | 'badChar' | 'uuidNotFound' = 'none'; // used for duplicate uuid warning
configLang = 'en';
currLang = 'en'; // page language
showDropdown = false;
Expand Down Expand Up @@ -736,7 +737,7 @@ export default class MetadataEditorV extends Vue {
};
slides: MultiLanguageSlide[] = [];
sourceCounts: SourceCounts = {};
sessionExpired = false;
sessionExpired: boolean = false;
totalTime = import.meta.env.VITE_APP_CURR_ENV ? Number(import.meta.env.VITE_SESSION_END) : 30;
mounted(): void {
Expand Down Expand Up @@ -2176,6 +2177,19 @@ export default class MetadataEditorV extends Vue {
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;
Expand Down
1 change: 1 addition & 0 deletions src/lang/lang.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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
Expand Down

0 comments on commit 6a734cb

Please sign in to comment.