aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgnattu <gnattuoc@me.com>2025-02-04 15:31:52 +0800
committergnattu <gnattuoc@me.com>2025-02-04 15:31:52 +0800
commit47af1c4576dbfbfd438bba248b582d1f312a84cd (patch)
tree5dd67ccc3f029533ba5aaa9bdcf60c76ba806576
parentd376b5fbc7cf3ae7440a606a9e885d70605956bd (diff)
Don't allow library name with leading or trailing space
Windows has a specific requirement on filenames that cannot have leading or trailing spaces and the folder creation would fail. Reject such request in the api controller.
-rw-r--r--Jellyfin.Api/Controllers/LibraryStructureController.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index 55000fc91e..eb2aba8814 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -81,6 +82,12 @@ public class LibraryStructureController : BaseJellyfinApiController
[FromBody] AddVirtualFolderDto? libraryOptionsDto,
[FromQuery] bool refreshLibrary = false)
{
+ // Windows does not allow files or folders with names that has leading or trailing spaces
+ if (name.Length != name.Trim().Length)
+ {
+ return BadRequest();
+ }
+
var libraryOptions = libraryOptionsDto?.LibraryOptions ?? new LibraryOptions();
if (paths is not null && paths.Length > 0)