aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/LibraryStructureController.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2026-08-30 14:40:16 -0400
committerGitHub <noreply@github.com>2026-08-30 14:40:16 -0400
commit9fe5a53e47526ae84b246ec3ae8f861056b52eca (patch)
treedd1319a5d805659eafa1a00a0aadcc394d950253 /Jellyfin.Api/Controllers/LibraryStructureController.cs
parent2996f726c19d65eb3fed0fbc42710278d1be3ec3 (diff)
parent0c560b22ce73323329645b836c9910abc257ce4e (diff)
Merge commit from fork
Secure library paths
Diffstat (limited to 'Jellyfin.Api/Controllers/LibraryStructureController.cs')
-rw-r--r--Jellyfin.Api/Controllers/LibraryStructureController.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index e46795554b..5c596c21b9 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -14,6 +14,7 @@ using MediaBrowser.Common.Api;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@@ -122,12 +123,14 @@ public class LibraryStructureController : BaseJellyfinApiController
/// <param name="newName">The new name.</param>
/// <param name="refreshLibrary">Whether to refresh the library.</param>
/// <response code="204">Folder renamed.</response>
+ /// <response code="400">The new name is not a valid library name.</response>
/// <response code="404">Library doesn't exist.</response>
/// <response code="409">Library already exists.</response>
- /// <returns>A <see cref="NoContentResult"/> on success, a <see cref="NotFoundResult"/> if the library doesn't exist, a <see cref="ConflictResult"/> if the new name is already taken.</returns>
+ /// <returns>A <see cref="NoContentResult"/> on success, a <see cref="BadRequestResult"/> if the new name is invalid, a <see cref="NotFoundResult"/> if the library doesn't exist, a <see cref="ConflictResult"/> if the new name is already taken.</returns>
/// <exception cref="ArgumentNullException">The new name may not be null.</exception>
[HttpPost("Name")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public ActionResult RenameVirtualFolder(
@@ -147,10 +150,15 @@ public class LibraryStructureController : BaseJellyfinApiController
var rootFolderPath = _appPaths.DefaultUserViewsPath;
- var currentPath = Path.Combine(rootFolderPath, name);
- var newPath = Path.Combine(rootFolderPath, newName);
+ // Both names are caller supplied, so they have to be confined to the libraries root.
+ var newPath = FileSystemHelper.GetChildPath(rootFolderPath, newName);
+ if (newPath is null)
+ {
+ return BadRequest("The new name is not a valid library name.");
+ }
- if (!Directory.Exists(currentPath))
+ var currentPath = FileSystemHelper.GetChildPath(rootFolderPath, name);
+ if (currentPath is null || !Directory.Exists(currentPath))
{
return NotFound("The media collection does not exist.");
}