[gnome-online-accounts] oauth2: Clean up



commit 3af2e335eb9ebedbe68724eee6ad4b285c6db8c5
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Oct 17 16:26:16 2013 +0200

    oauth2: Clean up
    
    Consolidate the ways in which the query and fragment are accessed.
    
    Fixes: https://bugzilla.gnome.org/710363

 src/goabackend/goaoauth2provider.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 37c15ce..ef6df3b 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -888,9 +888,13 @@ on_web_view_navigation_policy_decision_requested (WebKitWebView             *web
     {
       SoupMessage *message;
       SoupURI *uri;
+      const gchar *fragment;
+      const gchar *query;
 
       message = webkit_network_request_get_message (request);
       uri = soup_message_get_uri (message);
+      fragment = soup_uri_get_fragment (uri);
+      query = soup_uri_get_query (uri);
 
       /* Two cases:
        * 1) we can have either the auth code in the query part of the
@@ -898,11 +902,11 @@ on_web_view_navigation_policy_decision_requested (WebKitWebView             *web
        * 2) the access_token and other information directly in the
        *    fragment part of the URI.
        */
-      if (soup_uri_get_query (uri) != NULL)
+      if (query != NULL)
         {
           GHashTable *key_value_pairs;
 
-          key_value_pairs = soup_form_decode (uri->query);
+          key_value_pairs = soup_form_decode (query);
 
           priv->authorization_code = g_strdup (g_hash_table_lookup (key_value_pairs, "code"));
           if (priv->authorization_code != NULL)
@@ -927,13 +931,13 @@ on_web_view_navigation_policy_decision_requested (WebKitWebView             *web
           g_hash_table_unref (key_value_pairs);
           webkit_web_policy_decision_ignore (policy_decision);
         }
-      else if (soup_uri_get_fragment (uri) != NULL)
+      else if (fragment != NULL)
         {
           GHashTable *key_value_pairs;
 
           /* fragment is encoded into a key/value pairs for the token and
            * expiration values, using the same syntax as a URL query */
-          key_value_pairs = soup_form_decode (soup_uri_get_fragment (uri));
+          key_value_pairs = soup_form_decode (fragment);
 
           /* We might use oauth2_proxy_extract_access_token() here but
            * we can also extract other information.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]