diff options
-rw-r--r-- | Duplicati/Library/Utility/Uri.cs | 13 | ||||
-rw-r--r-- | Duplicati/Server/Database/Backup.cs | 17 |
2 files changed, 24 insertions, 6 deletions
diff --git a/Duplicati/Library/Utility/Uri.cs b/Duplicati/Library/Utility/Uri.cs index 6ba4e75ee..0cb746cf3 100644 --- a/Duplicati/Library/Utility/Uri.cs +++ b/Duplicati/Library/Utility/Uri.cs @@ -444,7 +444,8 @@ namespace Duplicati.Library.Utility /// </summary>
/// <returns>The parsed query string</returns>
/// <param name="query">The query to parse</param>
- public static NameValueCollection ParseQueryString(string query)
+ /// <param name="decodeValues">Whether to the parameter values should be decoded or not.</param>
+ public static NameValueCollection ParseQueryString(string query, bool decodeValues = true)
{
if (query == null)
throw new ArgumentNullException(nameof(query));
@@ -455,7 +456,15 @@ namespace Duplicati.Library.Utility var result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
foreach (System.Text.RegularExpressions.Match m in RE_URLPARAM.Matches(query))
- result.Add(UrlDecode(m.Groups["key"].Value), UrlDecode(m.Groups["value"].Success ? m.Groups["value"].Value : ""));
+ {
+ string value = m.Groups["value"].Success ? m.Groups["value"].Value : "";
+ if (decodeValues)
+ {
+ value = UrlDecode(value);
+ }
+
+ result.Add(UrlDecode(m.Groups["key"].Value), value);
+ }
return result;
}
diff --git a/Duplicati/Server/Database/Backup.cs b/Duplicati/Server/Database/Backup.cs index 962fb1081..117253942 100644 --- a/Duplicati/Server/Database/Backup.cs +++ b/Duplicati/Server/Database/Backup.cs @@ -18,6 +18,7 @@ using System;
using Duplicati.Server.Serialization.Interface;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Linq;
namespace Duplicati.Server.Database
@@ -121,11 +122,19 @@ namespace Duplicati.Server.Database public void SanitizeTargetUrl()
{
var url = new Duplicati.Library.Utility.Uri(this.TargetURL);
- var filteredParameters = url.QueryParameters;
- foreach (string field in UrlPasswords) {
- filteredParameters.Remove(field);
+ NameValueCollection filteredParameters = new NameValueCollection();
+ if (url.Query != null)
+ {
+ // We cannot use url.QueryParameters since it contains decoded parameter values, which
+ // breaks assumptions made by the decode_uri function in AppUtils.js. Since we are simply
+ // removing password parameters, we will leave the parameters as they are in the target URL.
+ filteredParameters = Library.Utility.Uri.ParseQueryString(url.Query, false);
+ foreach (string field in this.UrlPasswords)
+ {
+ filteredParameters.Remove(field);
+ }
}
- url = url.SetQuery(Duplicati.Library.Utility.Uri.BuildUriQuery(url.QueryParameters));
+ url = url.SetQuery(Duplicati.Library.Utility.Uri.BuildUriQuery(filteredParameters));
this.TargetURL = url.ToString();
}
|