aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/HlsSegmentController.cs
diff options
context:
space:
mode:
authorMarc Brooks <IDisposable@gmail.com>2026-06-28 16:26:35 -0500
committerMarc Brooks <IDisposable@gmail.com>2026-06-28 16:26:35 -0500
commit95cebffa8782e8ce8dc48a15c9723ce9f33cb09c (patch)
tree6c3e667a2870c036b5117bfa9c3d92be8e07b305 /Jellyfin.Api/Controllers/HlsSegmentController.cs
parent617ebf367ff24ecbe8e0de5aebc90fe28689bcb0 (diff)
Add tests
Also fixed a sibling directory that matches the prefix.
Diffstat (limited to 'Jellyfin.Api/Controllers/HlsSegmentController.cs')
-rw-r--r--Jellyfin.Api/Controllers/HlsSegmentController.cs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Jellyfin.Api/Controllers/HlsSegmentController.cs b/Jellyfin.Api/Controllers/HlsSegmentController.cs
index 4cb7627559..c61ee45830 100644
--- a/Jellyfin.Api/Controllers/HlsSegmentController.cs
+++ b/Jellyfin.Api/Controllers/HlsSegmentController.cs
@@ -164,10 +164,10 @@ public class HlsSegmentController : BaseJellyfinApiController
private string? ValidateTranscodePath(string filename)
{
- var transcodePath = _serverConfigurationManager.GetTranscodePath();
+ var transcodePath = Path.TrimEndingDirectorySeparator(Path.GetFullPath(_serverConfigurationManager.GetTranscodePath()));
var file = Path.GetFullPath(filename, transcodePath);
- var fileDir = Path.GetDirectoryName(file);
- if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath, StringComparison.OrdinalIgnoreCase))
+ // Require a separator after the transcode path so a sibling like "<transcodePath>-evil" can't pass.
+ if (!file.StartsWith(transcodePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return null;
}