Strip errant whitespace during path normalization (fixes #874)

This commit is contained in:
Matt Nadareski
2025-07-14 12:58:44 -04:00
parent 0160366530
commit 28205e42f0
5 changed files with 24 additions and 21 deletions

View File

@@ -81,6 +81,12 @@ namespace MPF.Frontend.Test.Tools
[InlineData("1.2.3.4..bin", true, "1.2.3.4..bin")]
[InlineData("dir/filename.bin", false, "dir/filename.bin")]
[InlineData("dir/filename.bin", true, "dir/filename.bin")]
[InlineData("dir /filename.bin", false, "dir/filename.bin")]
[InlineData("dir /filename.bin", true, "dir/filename.bin")]
[InlineData("dir/ filename.bin", false, "dir/filename.bin")]
[InlineData("dir/ filename.bin", true, "dir/filename.bin")]
[InlineData(" dir/filename.bin", false, "dir/filename.bin")]
[InlineData(" dir/filename.bin", true, "dir/filename.bin")]
[InlineData("\0dir/\0filename.bin", false, "_dir/_filename.bin")]
[InlineData("\0dir/\0filename.bin", true, "_dir/_filename.bin")]
public void NormalizeOutputPathsTest(string? path, bool getFullPath, string expected)

View File

@@ -9,24 +9,6 @@ namespace MPF.Frontend.Test.Tools
{
public class InfoToolTests
{
[Theory]
[InlineData(null, "")]
[InlineData(" ", " ")]
[InlineData("super\\blah.bin", "super\\blah.bin")]
[InlineData("super\\hero\\blah.bin", "super\\hero\\blah.bin")]
[InlineData("super.hero\\blah.bin", "super.hero\\blah.bin")]
[InlineData("superhero\\blah.rev.bin", "superhero\\blah.rev.bin")]
[InlineData("super&hero\\blah.bin", "super&hero\\blah.bin")]
[InlineData("superhero\\blah&foo.bin", "superhero\\blah&foo.bin")]
public void NormalizeOutputPathsTest(string? outputPath, string? expectedPath)
{
if (!string.IsNullOrEmpty(expectedPath))
expectedPath = Path.GetFullPath(expectedPath);
string actualPath = FrontendTool.NormalizeOutputPaths(outputPath, true);
Assert.Equal(expectedPath, actualPath);
}
[Fact]
public void ProcessSpecialFieldsCompleteTest()
{