From e83f45e75c01e92d30b6a161d9b7cdc702fe2c10 Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 4 Feb 2025 16:31:22 +0800 Subject: [PATCH] Don't allow library name with leading or trailing space --- .../mediaLibraryCreator/mediaLibraryCreator.js | 12 ++++++++++++ src/strings/en-us.json | 1 + 2 files changed, 13 insertions(+) diff --git a/src/components/mediaLibraryCreator/mediaLibraryCreator.js b/src/components/mediaLibraryCreator/mediaLibraryCreator.js index cb2a85dbbf..50eabad2a1 100644 --- a/src/components/mediaLibraryCreator/mediaLibraryCreator.js +++ b/src/components/mediaLibraryCreator/mediaLibraryCreator.js @@ -45,6 +45,18 @@ function onAddLibrary(e) { const name = dlg.querySelector('#txtValue').value; let type = dlg.querySelector('#selectCollectionType').value; + if (name.length == 0 || name.trim().length !== name.length) { + alert({ + text: globalize.translate('LibraryNameInvalid'), + type: 'error' + }); + + isCreating = false; + loading.hide(); + + return false; + } + if (type == 'mixed') { type = null; } diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 9c69f90285..cedcb4ae54 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1012,6 +1012,7 @@ "LeaveBlankToNotSetAPassword": "You can leave this field blank to set no password.", "Letterer": "Letterer", "LibraryAccessHelp": "Select the libraries to share with this user. Administrators will be able to edit all folders using the metadata manager.", + "LibraryNameInvalid": "Library name cannot be empty or have leading/trailing spaces.", "LibraryScanFanoutConcurrency": "Parallel library scan tasks limit", "LibraryScanFanoutConcurrencyHelp": "Maximum number of parallel tasks during library scans. Setting this to 0 will choose a limit based on your systems core count. WARNING: Setting this number too high may cause issues with network file systems; if you encounter problems lower this number.", "LibraryInvalidItemIdError": "The library is in an invalid state and cannot be edited. You are possibly encountering a bug: the path in the database is not the correct path on the filesystem.",