Skip to content

Commit 87b00c1

Browse files
committed
wip: Prevent users from creating guided mode datasets with forbidden characters
1 parent e25600b commit 87b00c1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/renderer/src/scripts/guided-mode/guided-curate-dataset.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1095,11 +1095,15 @@ const savePageChanges = async (pageBeingLeftID) => {
10951095
message: "Please enter a dataset name.",
10961096
});
10971097
}
1098-
if (check_forbidden_characters_ps(datasetNameInput)) {
1098+
1099+
const datasetNameContainsForbiddenCharacters = window.evaluateStringAgainstSdsRequirements(
1100+
datasetNameInput,
1101+
"string-contains-forbidden-characters"
1102+
);
1103+
if (datasetNameContainsForbiddenCharacters) {
10991104
errorArray.push({
11001105
type: "notyf",
1101-
message:
1102-
"A Pennsieve dataset name cannot contain any of the following characters: /:*?'<>.",
1106+
message: `A Pennsieve dataset name cannot contain any of the following characters: @#$%^&*()+=/\|"'~;:<>{}[]?`,
11031107
});
11041108
}
11051109
if (!datasetSubtitleInput) {

src/renderer/src/scripts/others/renderer.js

+2
Original file line numberDiff line numberDiff line change
@@ -4359,13 +4359,15 @@ const namesOfForbiddenFiles = {
43594359

43604360
const sparcFolderAndFileRegex = /[\+&\%#]/;
43614361
const identifierConventionsRegex = /^[a-zA-Z0-9-_]+$/;
4362+
const forbiddenCharacters = /[@#$%^&*()+=\/\\|"'~;:<>{}\[\]?]/;
43624363

43634364
window.evaluateStringAgainstSdsRequirements = (stringToTest, stringCase) => {
43644365
const testCases = {
43654366
"folder-and-file-name-is-valid": !sparcFolderAndFileRegex.test(stringToTest), // returns true if the string is valid
43664367
"file-is-hidden": stringToTest.startsWith("."), // returns true if the string is hidden
43674368
"file-is-in-forbidden-files-list": namesOfForbiddenFiles?.[stringToTest], // returns true if the string is in the forbidden files list
43684369
"string-adheres-to-identifier-conventions": identifierConventionsRegex.test(stringToTest), // returns true if the string adheres to the identifier conventions
4370+
"string-contains-forbidden-characters": forbiddenCharacters.test(stringToTest), // returns true if the string contains forbidden characters
43694371
};
43704372
return testCases[stringCase];
43714373
};

0 commit comments

Comments
 (0)