diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-12 19:04:25 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-12 19:04:25 -0500 |
| commit | fe1a6a3298116bc3980306cbb287f7137b378d1a (patch) | |
| tree | ad26e0f7f85a17ddb5cd97bbda61646873bb0a8e /src | |
| parent | 6367208d8255f33af83a3cfd7cf2d29897caee5c (diff) | |
| download | slskd-fe1a6a3298116bc3980306cbb287f7137b378d1a.tar.gz | |
tweak IsAllowed test
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Files/FileService.cs | 4 |
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))) |
