const isNewNote = computed(() => !props.title);
const loadingIndicator = ref();
const note = ref({});
+const reservedFilenameCharacters = /[<>:"/\\|?*]/;
const router = useRouter();
const newTitle = ref();
const toast = useToast();
}
}
+function entityTooLargeToast(entityName) {
+ toast.add(
+ getToastOptions(
+ "Failure",
+ `This ${entityName} is too large. Please try again with a smaller ${entityName} or adjust your server configuration.`,
+ true,
+ ),
+ );
+}
+
+function badFilenameToast(entityName) {
+ toast.add(
+ getToastOptions(
+ `Invalid ${entityName}`,
+ "Due to filename restrictions, the following characters are not allowed: <>:\"/\\|?*",
+ true,
+ ),
+ );
+}
+
function editHandler() {
newTitle.value = note.value.title;
editMode.value = true;
}
function saveHandler() {
+ if (reservedFilenameCharacters.test(newTitle.value)) {
+ badFilenameToast("Title");
+ return;
+ }
let newContent = toastEditor.value.getMarkdown();
if (isNewNote.value) {
saveNew(newTitle.value, newContent);
),
);
} else if (error.response?.status === 413) {
- toast.add(
- getToastOptions(
- "Failure",
- "This note is too large. Please try again with a smaller note or adjust your server configuration.",
- true,
- ),
- );
+ entityTooLargeToast("note");
} else {
apiErrorHandler(error, toast);
}