aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Files/FileService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-05-16 08:46:05 -0500
committerGitHub <noreply@github.com>2026-05-16 08:46:05 -0500
commit0dd1816a23de863ce33330b581e63447ddfb066e (patch)
treed0ce20082c735ea1c3337720b89aa4ae7b93c398 /src/slskd/Files/FileService.cs
parent2d7d768c5b60713b9886e89773a1eadc0091d132 (diff)
parent9bb822122182b88579b0498bb0ebfca94282e9b4 (diff)
downloadslskd-0dd1816a23de863ce33330b581e63447ddfb066e.tar.gz
Merge branch 'master' into dependabot/npm_and_yarn/src/web/axios-1.15.2
Diffstat (limited to 'src/slskd/Files/FileService.cs')
-rw-r--r--src/slskd/Files/FileService.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/slskd/Files/FileService.cs b/src/slskd/Files/FileService.cs
index 575619d5..4b281863 100644
--- a/src/slskd/Files/FileService.cs
+++ b/src/slskd/Files/FileService.cs
@@ -164,7 +164,7 @@ namespace slskd.Files
}
// important! we must fully expand the given paths with GetFullPath() to resolve a given relative directory, like '..'
- bool IsAllowed(string path) => AllowedDirectories.Any(allowed => path.StartsWith(allowed));
+ bool IsAllowed(string path) => AllowedDirectories.Any(allowed => path.StartsWith(allowed + Path.DirectorySeparatorChar) || path == allowed);
// if any of the resolved directory paths aren't rooted in one of the allowed directories, forbid the entire request
if (!directories.All(directory => IsAllowed(directory)))
@@ -222,7 +222,7 @@ namespace slskd.Files
}
// important! we must fully expand the given paths with GetFullPath() to resolve a given relative directory, like '..'
- bool IsAllowed(string path) => AllowedDirectories.Any(allowed => path.StartsWith(allowed));
+ bool IsAllowed(string path) => AllowedDirectories.Any(allowed => path.StartsWith(allowed + Path.DirectorySeparatorChar) || path == allowed);
// if any of the resolved file paths aren't rooted in one of the allowed directories, forbid the entire request
if (!files.All(file => IsAllowed(file)))