From 4456adc433821f9f4496d62ee72ac17ce0169884 Mon Sep 17 00:00:00 2001 From: 4m1g0 Date: Mon, 12 Sep 2016 13:36:08 +0200 Subject: [PATCH] Fix restore remote backup, bug introduced in: 6096d8379bca4acb16b52a84e5f18108c63e8643 --- .../Server/WebServer/RESTMethods/Backup.cs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Duplicati/Server/WebServer/RESTMethods/Backup.cs b/Duplicati/Server/WebServer/RESTMethods/Backup.cs index ffce432b4..8e0e8d001 100644 --- a/Duplicati/Server/WebServer/RESTMethods/Backup.cs +++ b/Duplicati/Server/WebServer/RESTMethods/Backup.cs @@ -172,16 +172,7 @@ namespace Duplicati.Server.WebServer.RESTMethods { var input = info.Request.Form; - string[] filters; - var rawpaths = (input["paths"].Value ?? string.Empty).Trim(); - - // We send the file list as a JSON array to avoid encoding issues with the path seperator - // as it is an allowed character in file and path names. - // We also accept the old way, for compatibility with the greeno theme - if (!string.IsNullOrWhiteSpace(rawpaths) && rawpaths.StartsWith("[", StringComparison.Ordinal) && rawpaths.EndsWith("]", StringComparison.Ordinal)) - filters = Newtonsoft.Json.JsonConvert.DeserializeObject(rawpaths); - else - filters = input["paths"].Value.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries); + string[] filters = parsePaths(input["paths"].Value ?? string.Empty); var time = Duplicati.Library.Utility.Timeparser.ParseTimeInterval(input["time"].Value, DateTime.Now); var restoreTarget = input["restore-path"].Value; @@ -234,6 +225,22 @@ namespace Duplicati.Server.WebServer.RESTMethods info.OutputOK(new { Status = "OK", ID = task.TaskID }); } + private string[] parsePaths(string paths) + { + string[] filters; + var rawpaths = (paths ?? string.Empty).Trim(); + + // We send the file list as a JSON array to avoid encoding issues with the path seperator + // as it is an allowed character in file and path names. + // We also accept the old way, for compatibility with the greeno theme + if (!string.IsNullOrWhiteSpace(rawpaths) && rawpaths.StartsWith("[", StringComparison.Ordinal) && rawpaths.EndsWith("]", StringComparison.Ordinal)) + filters = Newtonsoft.Json.JsonConvert.DeserializeObject(rawpaths); + else + filters = paths.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries); + + return filters; + } + private void DoRepair(IBackup backup, RequestInfo info, bool repairUpdate) { var input = info.Request.Form; @@ -246,7 +253,7 @@ namespace Duplicati.Server.WebServer.RESTMethods if (input["version"].Value != null) extra["version"] = input["version"].Value; if (input["paths"].Value != null) - filters = input["paths"].Value.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries); + filters = parsePaths(input["paths"].Value); var task = Runner.CreateTask(repairUpdate ? DuplicatiOperation.RepairUpdate : DuplicatiOperation.Repair, backup, extra, filters); Program.WorkThread.AddTask(task);