diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-21 11:48:08 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-21 11:48:08 +0100 | 
| commit | e14b47b826594772e4f3d0dbec1bf17153aa92b1 (patch) | |
| tree | 24964b04778df558ceaa88e9e241b4fd422299bd | |
| parent | 68286eb08dbb6c2aad555f155da6f16ee6f061e8 (diff) | |
Fix parsing of acc->pass. Use oauth_params_ functions instead of string
magic, fixes escaping issues.
| -rw-r--r-- | protocols/jabber/jabber.c | 16 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 1 | ||||
| -rw-r--r-- | protocols/jabber/sasl.c | 12 | 
3 files changed, 12 insertions, 17 deletions
| diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index f631a74e..11980d13 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -31,6 +31,7 @@  #include "xmltree.h"  #include "bitlbee.h"  #include "jabber.h" +#include "oauth.h"  #include "md5.h"  GSList *jabber_connections; @@ -137,6 +138,9 @@ static void jabber_login( account_t *acc )  	if( set_getbool( &acc->set, "oauth" ) )  	{ +		GSList *p_in = NULL; +		const char *tok; +		  		jd->fd = jd->r_inpa = jd->w_inpa = -1;  		if( strstr( jd->server, ".live.com" ) ) @@ -146,18 +150,20 @@ static void jabber_login( account_t *acc )  		else  			jd->oauth2_service = &oauth2_service_google; +		oauth_params_parse( &p_in, ic->acc->pass ); +		  		/* First see if we have a refresh token, in which case any  		   access token we *might* have has probably expired already  		   anyway. */ -		if( strstr( acc->pass, "refresh_token=" ) ) +		if( ( tok = oauth_params_get( &p_in, "refresh_token" ) ) )  		{ -			sasl_oauth2_refresh( ic, acc->pass + 14 ); +			sasl_oauth2_refresh( ic, tok );  		}  		/* If we don't have a refresh token, let's hope the access  		   token is still usable. */ -		else if( strstr( acc->pass, "access_token=" ) ) +		else if( ( tok = oauth_params_get( &p_in, "access_token" ) ) )  		{ -			sasl_oauth2_load_access_token( ic ); +			jd->oauth2_access_token = g_strdup( tok );  			jabber_connect( ic );  		}  		/* If we don't have any, start the OAuth process now. Don't @@ -167,6 +173,8 @@ static void jabber_login( account_t *acc )  			sasl_oauth2_init( ic );  			ic->flags |= OPT_SLOW_LOGIN;  		} +		 +		oauth_params_free( &p_in );  	}  	else  		jabber_connect( ic ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 85bcfafe..49cfe8ee 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -328,7 +328,6 @@ gboolean sasl_supported( struct im_connection *ic );  void sasl_oauth2_init( struct im_connection *ic );  int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg );  int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token ); -int sasl_oauth2_load_access_token( struct im_connection *ic );  extern const struct oauth2_service oauth2_service_google;  extern const struct oauth2_service oauth2_service_facebook; diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index 06dda8a8..2f45eb20 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -511,18 +511,6 @@ int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token )  	                            refresh_token, sasl_oauth2_got_token, ic );  } -int sasl_oauth2_load_access_token( struct im_connection *ic ) -{ -	struct jabber_data *jd = ic->proto_data; -	GSList *p_in = NULL; -	 -	oauth_params_parse( &p_in, ic->acc->pass ); -	jd->oauth2_access_token = g_strdup( oauth_params_get( &p_in, "access_token" ) ); -	oauth_params_free( &p_in ); -	 -	return jd->oauth2_access_token != NULL; -} -  static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token )  {  	struct im_connection *ic = data; | 
