Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Duplicati/Library/Utility/FilterExpression.cs5
-rw-r--r--Duplicati/UnitTest/ProblematicPathTests.cs33
2 files changed, 26 insertions, 12 deletions
diff --git a/Duplicati/Library/Utility/FilterExpression.cs b/Duplicati/Library/Utility/FilterExpression.cs
index fc4eb1745..60ca22588 100644
--- a/Duplicati/Library/Utility/FilterExpression.cs
+++ b/Duplicati/Library/Utility/FilterExpression.cs
@@ -81,14 +81,15 @@ namespace Duplicati.Library.Utility
/// The multiple wildcard character (DOS style)
/// </summary>
private const char MULTIPLE_WILDCARD = '*';
-
+
/// <summary>
/// The regular expression flags
/// </summary>
private static readonly RegexOptions REGEXP_OPTIONS =
RegexOptions.Compiled |
RegexOptions.ExplicitCapture |
- (Utility.IsFSCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
+ (Utility.IsFSCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase) |
+ RegexOptions.Singleline;
// Since we might need to get the regex for a particular filter group multiple times
// (e.g., when combining multiple FilterExpressions together, which discards the existing FilterEntries and recreates them from the Filter representations),
diff --git a/Duplicati/UnitTest/ProblematicPathTests.cs b/Duplicati/UnitTest/ProblematicPathTests.cs
index e470f67c3..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);
@@ -274,6 +281,8 @@ namespace Duplicati.UnitTest
}
Dictionary<string, string> restoreOptions = new Dictionary<string, string>(this.TestOptions) {["restore-path"] = this.RESTOREFOLDER};
+
+ // Restore just the file.
using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null))
{
IRestoreResults restoreResults = c.Restore(new[] {filePath});
@@ -282,15 +291,19 @@ namespace Duplicati.UnitTest
}
string restoreFilePath = SystemIO.IO_OS.PathCombine(this.RESTOREFOLDER, pathComponent);
- Assert.IsTrue(SystemIO.IO_OS.FileExists(restoreFilePath));
+ TestUtils.AssertFilesAreEqual(filePath, restoreFilePath, true, pathComponent);
+ SystemIO.IO_OS.FileDelete(restoreFilePath);
- MemoryStream restoredStream = new MemoryStream();
- using (FileStream fileStream = SystemIO.IO_OS.FileOpenRead(restoreFilePath))
+ // Restore the entire directory.
+ string pathSpec = $"[{Regex.Escape(Util.AppendDirSeparator(this.DATAFOLDER))}.*]";
+ using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null))
{
- Utility.CopyStream(fileStream, restoredStream);
+ IRestoreResults restoreResults = c.Restore(new[] {pathSpec});
+ Assert.AreEqual(0, restoreResults.Errors.Count());
+ Assert.AreEqual(0, restoreResults.Warnings.Count());
}
- Assert.AreEqual(fileBytes, restoredStream.ToArray());
+ TestUtils.AssertDirectoryTreesAreEquivalent(this.DATAFOLDER, this.RESTOREFOLDER, true, pathComponent);
}
}
} \ No newline at end of file