From a229062e6f747f3d49e81f68ea2b2202a46a9754 Mon Sep 17 00:00:00 2001 From: gl3nni3 Date: Sun, 5 Jan 2020 02:52:45 +0100 Subject: [PATCH] Fixed: Replace duplicate slashes from file names when importing Fixes #3470 --- src/NzbDrone.Common.Test/OsPathFixture.cs | 9 +++++++++ src/NzbDrone.Common/Disk/OsPath.cs | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common.Test/OsPathFixture.cs b/src/NzbDrone.Common.Test/OsPathFixture.cs index 6d79e0cfc..c31abefc7 100644 --- a/src/NzbDrone.Common.Test/OsPathFixture.cs +++ b/src/NzbDrone.Common.Test/OsPathFixture.cs @@ -185,6 +185,15 @@ namespace NzbDrone.Common.Test osPath.FullPath.Should().Be(@"/just/a/test/to/verify the/slashes/"); } + [Test] + public void should_fix_double_slashes_unix() + { + var osPath = new OsPath(@"/just/a//test////to/verify the/slashes/"); + + osPath.Kind.Should().Be(OsPathKind.Unix); + osPath.FullPath.Should().Be(@"/just/a/test/to/verify the/slashes/"); + } + [Test] public void should_combine_mixed_slashes() { diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs index 02aaf6561..0cc853cb7 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -85,7 +85,13 @@ namespace NzbDrone.Common.Disk case OsPathKind.Windows: return path.Replace('/', '\\'); case OsPathKind.Unix: - return path.Replace('\\', '/'); + path = path.Replace('\\', '/'); + while (path.Contains("//")) + { + path = path.Replace("//", "/"); + } + + return path; } return path;