aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-07-23 17:48:30 -0500
committerJP Dillingham <jp@dillingham.me>2023-07-23 17:48:30 -0500
commit8ed1baaa3bccf32490924920b8ff38c5812aa8c3 (patch)
tree3dfdabea33035e9aa07ac6a4a4191f03fa52757d /src
parent5c139be17a369039dde9033ebb0ec2de20f4c6fc (diff)
downloadslskd-8ed1baaa3bccf32490924920b8ff38c5812aa8c3.tar.gz
ensure relative paths are supplied
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Files/API/FilesController.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/slskd/Files/API/FilesController.cs b/src/slskd/Files/API/FilesController.cs
index 2bb2d051..372e5f5e 100644
--- a/src/slskd/Files/API/FilesController.cs
+++ b/src/slskd/Files/API/FilesController.cs
@@ -19,14 +19,12 @@ using Microsoft.Extensions.Options;
namespace slskd.Files.API
{
- using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Security;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
- using OneOf;
using Serilog;
/// <summary>
@@ -218,7 +216,8 @@ namespace slskd.Files.API
var requestedDir = base64SubdirectoryName
.FromBase64()
.Replace('\\', Path.DirectorySeparatorChar)
- .Replace('/', Path.DirectorySeparatorChar);
+ .Replace('/', Path.DirectorySeparatorChar)
+ .TrimStart(Path.DirectorySeparatorChar);
requestedDir = Path.GetFullPath(Path.Combine(rootDirectory, requestedDir));
@@ -254,7 +253,8 @@ namespace slskd.Files.API
var requestedFilename = base64FileName
.FromBase64()
.Replace('\\', Path.DirectorySeparatorChar)
- .Replace('/', Path.DirectorySeparatorChar);
+ .Replace('/', Path.DirectorySeparatorChar)
+ .TrimStart(Path.DirectorySeparatorChar);
requestedFilename = Path.GetFullPath(Path.Combine(rootDirectory, requestedFilename));