diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-16 08:46:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-16 08:46:43 -0500 |
| commit | bdfb99300ed473791f23a0937d00e6d36250f39c (patch) | |
| tree | 76c49451de8b072a2d137c81c508242cad9a5207 /src/slskd/Files/FileService.cs | |
| parent | 072d9ad430042d1666f3260a57608119ffead254 (diff) | |
| parent | f37740a6eaee8ee04b5b517ba186b7f523aa271f (diff) | |
| download | slskd-bdfb99300ed473791f23a0937d00e6d36250f39c.tar.gz | |
Merge branch 'master' into dependabot/npm_and_yarn/src/web/fast-uri-3.1.2
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))) |
