Changeset e14b47b


Ignore:
Timestamp:
2011-12-21T10:48:08Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
ce199b7
Parents:
68286eb
Message:

Fix parsing of acc->pass. Use oauth_params_ functions instead of string
magic, fixes escaping issues.

Location:
protocols/jabber
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r68286eb re14b47b  
    3232#include "bitlbee.h"
    3333#include "jabber.h"
     34#include "oauth.h"
    3435#include "md5.h"
    3536
     
    138139        if( set_getbool( &acc->set, "oauth" ) )
    139140        {
     141                GSList *p_in = NULL;
     142                const char *tok;
     143               
    140144                jd->fd = jd->r_inpa = jd->w_inpa = -1;
    141145               
     
    147151                        jd->oauth2_service = &oauth2_service_google;
    148152               
     153                oauth_params_parse( &p_in, ic->acc->pass );
     154               
    149155                /* First see if we have a refresh token, in which case any
    150156                   access token we *might* have has probably expired already
    151157                   anyway. */
    152                 if( strstr( acc->pass, "refresh_token=" ) )
     158                if( ( tok = oauth_params_get( &p_in, "refresh_token" ) ) )
    153159                {
    154                         sasl_oauth2_refresh( ic, acc->pass + 14 );
     160                        sasl_oauth2_refresh( ic, tok );
    155161                }
    156162                /* If we don't have a refresh token, let's hope the access
    157163                   token is still usable. */
    158                 else if( strstr( acc->pass, "access_token=" ) )
     164                else if( ( tok = oauth_params_get( &p_in, "access_token" ) ) )
    159165                {
    160                         sasl_oauth2_load_access_token( ic );
     166                        jd->oauth2_access_token = g_strdup( tok );
    161167                        jabber_connect( ic );
    162168                }
     
    168174                        ic->flags |= OPT_SLOW_LOGIN;
    169175                }
     176               
     177                oauth_params_free( &p_in );
    170178        }
    171179        else
  • protocols/jabber/jabber.h

    r68286eb re14b47b  
    329329int sasl_oauth2_get_refresh_token( struct im_connection *ic, const char *msg );
    330330int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token );
    331 int sasl_oauth2_load_access_token( struct im_connection *ic );
    332331
    333332extern const struct oauth2_service oauth2_service_google;
  • protocols/jabber/sasl.c

    r68286eb re14b47b  
    512512}
    513513
    514 int sasl_oauth2_load_access_token( struct im_connection *ic )
    515 {
    516         struct jabber_data *jd = ic->proto_data;
    517         GSList *p_in = NULL;
    518        
    519         oauth_params_parse( &p_in, ic->acc->pass );
    520         jd->oauth2_access_token = g_strdup( oauth_params_get( &p_in, "access_token" ) );
    521         oauth_params_free( &p_in );
    522        
    523         return jd->oauth2_access_token != NULL;
    524 }
    525 
    526514static void sasl_oauth2_got_token( gpointer data, const char *access_token, const char *refresh_token )
    527515{
Note: See TracChangeset for help on using the changeset viewer.