summaryrefslogtreecommitdiff
path: root/plugins/common/OAuth1Support.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
commit31804433d72460cbe0a39f9f8ea5e76058d84cda (patch)
tree2084a84c39f159c6aea254775dc0880d52579d45 /plugins/common/OAuth1Support.vala
parenta9898fb3f39c44a85876930ef6b2558052569ae6 (diff)
parentd443a3c2509889533ca812c163056bace396b586 (diff)
Update upstream source from tag 'upstream/0.32.1'
Update to upstream version '0.32.1' with Debian dir c460ad6e13d3c39eaa2d5399059385e64e6fba4c
Diffstat (limited to 'plugins/common/OAuth1Support.vala')
-rw-r--r--plugins/common/OAuth1Support.vala25
1 files changed, 10 insertions, 15 deletions
diff --git a/plugins/common/OAuth1Support.vala b/plugins/common/OAuth1Support.vala
index e5a8545..05ba34f 100644
--- a/plugins/common/OAuth1Support.vala
+++ b/plugins/common/OAuth1Support.vala
@@ -6,7 +6,6 @@
*/
namespace Publishing.RESTSupport.OAuth1 {
- internal const string ENCODE_RFC_3986_EXTRA = "!*'();:@&=+$,/?%#[] \\";
public class Session : Publishing.RESTSupport.Session {
private string? request_phase_token = null;
@@ -62,7 +61,7 @@ namespace Publishing.RESTSupport.OAuth1 {
Publishing.RESTSupport.Argument[] sorted_args =
Publishing.RESTSupport.Argument.sort(base_string_arguments);
- var arguments_string = Argument.serialize_list(sorted_args);
+ var arguments_string = Argument.serialize_for_sbs(sorted_args);
string? signing_key = null;
if (access_phase_token_secret != null) {
@@ -80,9 +79,9 @@ namespace Publishing.RESTSupport.OAuth1 {
signing_key = consumer_secret + "&";
}
- string signature_base_string = http_method + "&" + Soup.URI.encode(
- txn.get_endpoint_url(), ENCODE_RFC_3986_EXTRA) + "&" +
- Soup.URI.encode(arguments_string, ENCODE_RFC_3986_EXTRA);
+ string signature_base_string = http_method + "&" + GLib.Uri.escape_string(
+ txn.get_endpoint_url()) + "&" +
+ GLib.Uri.escape_string (arguments_string);
debug("signature base string = '%s'", signature_base_string);
@@ -90,7 +89,7 @@ namespace Publishing.RESTSupport.OAuth1 {
// compute the signature
string signature = RESTSupport.hmac_sha1(signing_key, signature_base_string);
- signature = Soup.URI.encode(signature, ENCODE_RFC_3986_EXTRA);
+ signature = GLib.Uri.escape_string(signature);
debug("signature = '%s'", signature);
@@ -111,11 +110,8 @@ namespace Publishing.RESTSupport.OAuth1 {
}
public string get_oauth_nonce() {
- TimeVal currtime = TimeVal();
- currtime.get_current_time();
-
- return Checksum.compute_for_string(ChecksumType.MD5, currtime.tv_sec.to_string() +
- currtime.tv_usec.to_string());
+ return Checksum.compute_for_string(ChecksumType.MD5,
+ GLib.get_real_time().to_string());
}
public string get_oauth_timestamp() {
@@ -178,12 +174,11 @@ namespace Publishing.RESTSupport.OAuth1 {
}
}
-
- public override void execute() throws Spit.Publishing.PublishingError {
+ public override async void execute_async() throws Spit.Publishing.PublishingError {
var signature = ((Session) get_parent_session()).sign_transaction(this);
add_argument("oauth_signature", signature);
- base.execute();
+ yield base.execute_async();
}
}
@@ -212,7 +207,7 @@ namespace Publishing.RESTSupport.OAuth1 {
}
public string get_authorization_header_string() {
- return "OAuth " + Argument.serialize_list(auth_header_fields, true, ", ");
+ return "OAuth " + Argument.serialize_list(auth_header_fields, false, true, ", ");
}
public void authorize() {