[shotwell] OAuth: Fix serialization of upload authorization
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] OAuth: Fix serialization of upload authorization
- Date: Thu, 16 Nov 2017 20:46:31 +0000 (UTC)
commit 807376fc2f2fdd718d1025b68ad4338146628eab
Author: Jens Georg <mail jensge org>
Date: Thu Nov 16 20:47:35 2017 +0100
OAuth: Fix serialization of upload authorization
plugins/common/RESTSupport.vala | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 6f54f96..5c02992 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -123,14 +123,16 @@ public class Argument {
this.value = value;
}
- public static string serialize_list(Argument[] args) {
+ public static string serialize_list(Argument[] args, bool escape = false, string? separator = "&") {
var builder = new StringBuilder("");
foreach (var arg in args) {
- builder.append(arg.to_string());
- builder.append("&");
+ builder.append(arg.to_string(escape));
+ builder.append(separator);
}
- builder.truncate(builder.len - 1);
+
+ if (builder.len > 0)
+ builder.truncate(builder.len - separator.length);
return builder.str;
}
@@ -148,8 +150,8 @@ public class Argument {
return sorted_args.to_array();
}
- public string to_string () {
- return "%s=%s".printf (this.key, this.value);
+ public string to_string (bool escape = false) {
+ return "%s=%s%s%s".printf (this.key, escape ? "\"" : "", this.value, escape ? "\"" : "");
}
}
@@ -1065,7 +1067,7 @@ namespace OAuth1 {
}
public string get_authorization_header_string() {
- return "OAuth " + Argument.serialize_list(auth_header_fields);
+ return "OAuth " + Argument.serialize_list(auth_header_fields, true, ", ");
}
public void authorize() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]