diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-14 18:37:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-14 18:37:28 -0500 |
| commit | 9bb822122182b88579b0498bb0ebfca94282e9b4 (patch) | |
| tree | 035d38c432787f33d1e4d0037e200b8ccb41cefa /src/slskd/Files/FileService.cs | |
| parent | 427a3de7bf2987bd15159f1f3b50bee1ae95e677 (diff) | |
| parent | e6cc409dbe1818b3cd60b2fe7241428684e2665f (diff) | |
| download | slskd-9bb822122182b88579b0498bb0ebfca94282e9b4.tar.gz | |
Merge pull request #1729 from slskd/paths-again
Paths again
Diffstat (limited to 'src/slskd/Files/FileService.cs')
| -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))) |
