Fixed: Allow leading/trailing spaces on non-Windows

(cherry picked from commit 9127a91dfc460f442498a00faed98737047098cd)

Closes #10240
pull/10296/head
Mark McDowall 4 months ago committed by Bogdan
parent 322df78f5a
commit 37c09ba1f8

@ -379,8 +379,17 @@ namespace NzbDrone.Common.Test
[TestCase(@" C:\Test\TV\")]
[TestCase(@" C:\Test\TV")]
public void IsPathValid_should_be_false(string path)
public void IsPathValid_should_be_false_on_windows(string path)
{
WindowsOnly();
path.IsPathValid(PathValidationType.CurrentOs).Should().BeFalse();
}
[TestCase(@"")]
[TestCase(@"relative/path")]
public void IsPathValid_should_be_false_on_unix(string path)
{
PosixOnly();
path.AsOsAgnostic().IsPathValid(PathValidationType.CurrentOs).Should().BeFalse();
}
}

@ -153,6 +153,9 @@ namespace NzbDrone.Common.Extensions
return false;
}
// Only check for leading or trailing spaces for path when running on Windows.
if (OsInfo.IsWindows)
{
var directoryInfo = new DirectoryInfo(path);
while (directoryInfo != null)
@ -164,6 +167,7 @@ namespace NzbDrone.Common.Extensions
directoryInfo = directoryInfo.Parent;
}
}
if (validationType == PathValidationType.AnyOs)
{

Loading…
Cancel
Save