aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-05-27 21:43:50 -0500
committerJP Dillingham <jp@dillingham.me>2026-05-27 21:43:50 -0500
commit89f2a6e19745f22a8f003556b743cbe87ec67cc8 (patch)
treeac84032d9c5c66e4a181937ed8fbe010e733a116 /src
parente711d6ad8b52e7ee6454b20bce0fcdbe12aaae91 (diff)
downloadslskd-89f2a6e19745f22a8f003556b743cbe87ec67cc8.tar.gz
strip soulseek qt prefixes too
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/FileSafety.cs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/slskd/Common/FileSafety.cs b/src/slskd/Common/FileSafety.cs
index aae14a25..06fd340d 100644
--- a/src/slskd/Common/FileSafety.cs
+++ b/src/slskd/Common/FileSafety.cs
@@ -63,6 +63,7 @@ public static class FileSafety
private static readonly Regex DriveRootRegex = new(@"^[a-zA-Z]:[/\\]?", RegexOptions.Compiled); // C: or C:\
private static readonly Regex UncRootRegex = new(@"^[/\\]{2}[^/\\]+[/\\]?", RegexOptions.Compiled); // \\server[\] or //server[/], any slash variants
+ private static readonly Regex SoulseekQtRootRegex = new(@"^@@[a-zA-Z0-9]{5,}[\/\\]", RegexOptions.Compiled); // @@abcde[\|/], a Soulseek Qt share prefix
/// <summary>
/// An alternative to <see cref="Path.Combine(string, string)"/> that disallows rooted segments in the second or
@@ -291,6 +292,9 @@ public static class FileSafety
path = DriveRootRegex.Replace(path, string.Empty);
path = UncRootRegex.Replace(path, string.Empty);
+ // strip @@abcde prefixes used by SoulseekQt to obscure paths
+ path = SoulseekQtRootRegex.Replace(path, string.Empty);
+
// for each segment, drop nulls (created by double slashes), sanitize, and replace traversal strings
var segments = path
.Split(sep)