diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2013-06-01 01:09:52 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2013-06-01 01:09:52 +0100 |
commit | f2d8aa21d47f2c5158df7dc51abce19611e9a81e (patch) | |
tree | 2e76fe6f8667e34694d82fcf990a509f859e3468 | |
parent | 420ddc005a5edd19ee5e0cb299e46b37f283d974 (diff) |
Emit a warning when the user wants to do OAuth with a non-Twitter/identi.ca
service, and string handling fix when pretending to do this anyway.
-rw-r--r-- | protocols/twitter/twitter.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index db61ba7c..6d8b3fd0 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -157,8 +157,13 @@ static const struct oauth_service *get_oauth_service(struct im_connection *ic) static void twitter_oauth_start(struct im_connection *ic) { struct twitter_data *td = ic->proto_data; + const char *url = set_getstr(&ic->acc->set, "base_url"); imcb_log(ic, "Requesting OAuth request token"); + + if (!strstr(url, "twitter.com") && !strstr(url, "identi.ca")) + imcb_log(ic, "Warning: OAuth only works with identi.ca and " + "Twitter."); td->oauth_info = oauth_request_token(get_oauth_service(ic), twitter_oauth_callback, ic); @@ -177,7 +182,7 @@ static gboolean twitter_oauth_callback(struct oauth_info *info) td = ic->proto_data; if (info->stage == OAUTH_REQUEST_TOKEN) { - char name[strlen(ic->acc->user) + 9], *msg; + char *name, *msg; if (info->request_token == NULL) { imcb_error(ic, "OAuth error: %s", twitter_parse_error(info->http)); @@ -185,11 +190,12 @@ static gboolean twitter_oauth_callback(struct oauth_info *info) return FALSE; } - sprintf(name, "%s_%s", td->prefix, ic->acc->user); + name = g_strdup_printf("%s_%s", td->prefix, ic->acc->user); msg = g_strdup_printf("To finish OAuth authentication, please visit " "%s and respond with the resulting PIN code.", info->auth_url); imcb_buddy_msg(ic, name, msg, 0, 0); + g_free(name); g_free(msg); } else if (info->stage == OAUTH_ACCESS_TOKEN) { const char *sn; |