diff --git a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs index 255a811cc..761c45bc9 100644 --- a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs +++ b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs @@ -160,7 +160,8 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive var curpath = new List(); foreach(var p in (altpath ?? m_path).Split(new string[] {"/"}, StringSplitOptions.RemoveEmptyEntries)) { - var self = m_oauth.GetJSONData(string.Format("{0}/nodes?filters=kind:{1}%20and%20parents:{2}%20and%20name:{3}", MetadataUrl, CONTENT_KIND_FOLDER, Utility.Uri.UrlEncode(parent.ID), Utility.Uri.UrlEncode(p))); + var requestUrl = string.Format("{0}/nodes?filters=kind:{1}%20and%20parents:{2}%20and%20name:{3}", MetadataUrl, CONTENT_KIND_FOLDER, Utility.Uri.UrlEncode(parent.ID), Utility.Uri.UrlPathEncode(EscapeFiltersValue(p))); + var self = m_oauth.GetJSONData(requestUrl); if (self == null || self.Count == 0 || self.Data == null || self.Data.Length == 0) { if (!createMissing) @@ -234,6 +235,15 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive throw new FileMissingException(); } + + private static System.Text.RegularExpressions.Regex FILTERS_VALUE_ESCAPECHAR = new System.Text.RegularExpressions.Regex(@"[+\-&|!(){}\[\]^'""~*?:\\ ]", System.Text.RegularExpressions.RegexOptions.Compiled); + + public static string EscapeFiltersValue(string value) + { + return FILTERS_VALUE_ESCAPECHAR.Replace(value, (m) => { + return @"\" + m.Value; + }); + } #region IStreamingBackend implementation public void Put(string remotename, System.IO.Stream stream)