diff --git a/src/NzbDrone.Common.Test/PathExtensionFixture.cs b/src/NzbDrone.Common.Test/PathExtensionFixture.cs index 2c9d8f7a5..5a54eb755 100644 --- a/src/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/src/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Text; using FluentAssertions; using Moq; using NUnit.Framework; @@ -433,5 +434,14 @@ namespace NzbDrone.Common.Test { parentPath.GetRelativePath(childPath).Should().Be(relativePath); } + + [Test] + public void should_be_equal_with_different_unicode_representations() + { + var path1 = @"C:\Test\file.mkv".AsOsAgnostic().Normalize(NormalizationForm.FormC); + var path2 = @"C:\Test\file.mkv".AsOsAgnostic().Normalize(NormalizationForm.FormD); + + path1.PathEquals(path2); + } } } diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index cbf82e41c..93e974638 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -55,6 +55,10 @@ namespace NzbDrone.Common.Extensions public static bool PathEquals(this string firstPath, string secondPath, StringComparison? comparison = null) { + // Normalize paths to ensure unicode characters are represented the same way + firstPath = firstPath.Normalize(); + secondPath = secondPath?.Normalize(); + if (!comparison.HasValue) { comparison = DiskProviderBase.PathStringComparison; diff --git a/src/NzbDrone.Common/PathEqualityComparer.cs b/src/NzbDrone.Common/PathEqualityComparer.cs index 5b9c3aa1c..bd6fa430d 100644 --- a/src/NzbDrone.Common/PathEqualityComparer.cs +++ b/src/NzbDrone.Common/PathEqualityComparer.cs @@ -21,10 +21,10 @@ namespace NzbDrone.Common { if (OsInfo.IsWindows) { - return obj.CleanFilePath().ToLower().GetHashCode(); + return obj.CleanFilePath().Normalize().ToLower().GetHashCode(); } - return obj.CleanFilePath().GetHashCode(); + return obj.CleanFilePath().Normalize().GetHashCode(); } } }