- Timestamp:
- 2010-04-27T22:11:11Z (15 years ago)
- Branches:
- master
- Children:
- 18dbb20
- Parents:
- 288b215
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth.c
r288b215 ree84bdb 101 101 sha1_finish( &sha1, hash ); 102 102 103 /* base64_encode it and we're done. */ 104 return base64_encode( hash, sha1_hash_size ); 103 /* base64_encode + HTTP escape it (both consumers 104 need it that away) and we're done. */ 105 s = base64_encode( hash, sha1_hash_size ); 106 s = g_realloc( s, strlen( s ) * 3 + 1 ); 107 http_encode( s ); 108 109 return s; 105 110 } 106 111 … … 108 113 { 109 114 unsigned char bytes[9]; 110 char *ret;111 115 112 116 random_bytes( bytes, sizeof( bytes ) ); 113 ret = base64_encode( bytes, sizeof( bytes ) ); 114 ret = g_realloc( ret, strlen( ret ) * 3 + 1 ); 115 http_encode( ret ); 116 117 return ret; 117 return base64_encode( bytes, sizeof( bytes ) ); 118 118 } 119 119 … … 167 167 static void oauth_params_parse( GSList **params, char *in ) 168 168 { 169 char *amp, *eq ;169 char *amp, *eq, *s; 170 170 171 171 while( in && *in ) … … 179 179 *amp = '\0'; 180 180 181 oauth_params_add( params, in, eq + 1 ); 181 s = g_strdup( eq + 1 ); 182 http_decode( s ); 183 oauth_params_add( params, in, s ); 184 g_free( s ); 182 185 183 186 *eq = '='; … … 206 209 for( l = params; l; l = l->next ) 207 210 { 208 g_string_append( str, l->data ); 211 char *s, *eq; 212 213 s = g_malloc( strlen( l->data ) * 3 + 1 ); 214 strcpy( s, l->data ); 215 if( ( eq = strchr( s, '=' ) ) ) 216 http_encode( eq + 1 ); 217 g_string_append( str, s ); 218 g_free( s ); 219 209 220 if( l->next ) 210 221 g_string_append_c( str, '&' ); … … 254 265 255 266 s = oauth_sign( "POST", url, params_s, NULL ); 256 s = g_realloc( s, strlen( s ) * 3 + 1 );257 http_encode( s );258 259 267 post = g_strdup_printf( "%s&oauth_signature=%s", params_s, s ); 260 268 g_free( params_s ); … … 390 398 params_s = oauth_params_string( params ); 391 399 sig = oauth_sign( method, url, params_s, token_secret ); 400 g_string_append_printf( ret, "oauth_signature=\"%s\"", sig ); 392 401 g_free( params_s ); 393 sig = g_realloc( sig, strlen( sig ) * 3 + 1 );394 http_encode( sig );395 396 g_string_append_printf( ret, "oauth_signature=\"%s\"", sig );397 402 398 403 err:
Note: See TracChangeset
for help on using the changeset viewer.