Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent addition of illegal characters to new/renamed UUIDs #556

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading