diff options
author | Kenneth Hsu <kennethhsu@gmail.com> | 2021-05-15 04:36:28 +0300 |
---|---|---|
committer | Kenneth Hsu <kennethhsu@gmail.com> | 2021-05-15 04:36:28 +0300 |
commit | a58f6b5d693bdadabe4211e499d6b6f42ee01d1e (patch) | |
tree | 33d0ac7bdb00e428fbb6f04cfcd88b9faccd727e | |
parent | 4cc7beea2c9297cfeeb335ffe71b4cc5d1b6d8e9 (diff) |
Add test for restoring file with newline character in name.
This concerns #4508.
-rw-r--r-- | Duplicati/UnitTest/ProblematicPathTests.cs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Duplicati/UnitTest/ProblematicPathTests.cs b/Duplicati/UnitTest/ProblematicPathTests.cs index 85d3cebd8..d0cd45537 100644 --- a/Duplicati/UnitTest/ProblematicPathTests.cs +++ b/Duplicati/UnitTest/ProblematicPathTests.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using Duplicati.Library.Common; using Duplicati.Library.Common.IO; using Duplicati.Library.Interface; @@ -252,12 +253,18 @@ namespace Duplicati.UnitTest [Test] [Category("ProblematicPath")] - [TestCase("ends_with_dot.")] - [TestCase("ends_with_dots..")] - [TestCase("ends_with_space ")] - [TestCase("ends_with_spaces ")] - public void ProblematicSuffixes(string pathComponent) + [TestCase("ends_with_dot.", false)] + [TestCase("ends_with_dots..", false)] + [TestCase("ends_with_space ", false)] + [TestCase("ends_with_spaces ", false)] + [TestCase("ends_with_newline\n", true)] + public void ProblematicSuffixes(string pathComponent, bool skipOnWindows) { + if (Platform.IsClientWindows && skipOnWindows) + { + return; + } + string folderPath = SystemIO.IO_OS.PathCombine(this.DATAFOLDER, pathComponent); SystemIO.IO_OS.DirectoryCreate(folderPath); @@ -288,7 +295,7 @@ namespace Duplicati.UnitTest SystemIO.IO_OS.FileDelete(restoreFilePath); // Restore the entire directory. - string pathSpec = $"[{Util.AppendDirSeparator(this.DATAFOLDER)}.*]"; + string pathSpec = $"[{Regex.Escape(Util.AppendDirSeparator(this.DATAFOLDER))}.*]"; using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) { IRestoreResults restoreResults = c.Restore(new[] {pathSpec}); |