/pidgin/main: 00cc81f9b809: Merged in EionRobb/pidgin (pull requ...
Gary Kramlich
grim at reaperworld.com
Sat Jan 23 14:06:34 EST 2016
Changeset: 00cc81f9b8090634fb514d3d0a0670115d2736f8
Author: Gary Kramlich <grim at reaperworld.com>
Date: 2016-01-23 12:57 -0600
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/00cc81f9b809
Description:
Merged in EionRobb/pidgin (pull request #12)
Cookie improvements to HTTP functions
diffstat:
libpurple/http.c | 22 +++++++++++++++++-----
libpurple/http.h | 4 +++-
libpurple/protocols/yahoo/ymsg.c | 20 +++++++++++++-------
3 files changed, 33 insertions(+), 13 deletions(-)
diffs (134 lines):
diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -24,8 +24,10 @@
#include "internal.h"
#include "glibcompat.h"
+
#include "debug.h"
#include "ntlm.h"
+#include "proxy.h"
#include "purple-socket.h"
#include <zlib.h>
@@ -1990,7 +1992,7 @@ static gchar * purple_http_cookie_jar_ge
while (g_hash_table_iter_next(&it, (gpointer*)&key,
(gpointer*)&cookie))
{
- if (cookie->expires != -1 && cookie->expires <= now)
+ if (cookie->expires != -1 && cookie->expires != 0 && cookie->expires <= now)
continue;
g_string_append_printf(str, "%s=%s; ", key, cookie->value);
}
@@ -2003,7 +2005,17 @@ static gchar * purple_http_cookie_jar_ge
void purple_http_cookie_jar_set(PurpleHttpCookieJar *cookie_jar,
const gchar *name, const gchar *value)
{
- purple_http_cookie_jar_set_ext(cookie_jar, name, value, -1);
+ gchar *escaped_name = g_strdup(purple_url_encode(name));
+ gchar *escaped_value = NULL;
+
+ if (escaped_value) {
+ escaped_value = g_strdup(purple_url_encode(value));
+ }
+
+ purple_http_cookie_jar_set_ext(cookie_jar, escaped_name, escaped_value, -1);
+
+ g_free(escaped_name);
+ g_free(escaped_value);
}
static void purple_http_cookie_jar_set_ext(PurpleHttpCookieJar *cookie_jar,
@@ -2012,7 +2024,7 @@ static void purple_http_cookie_jar_set_e
g_return_if_fail(cookie_jar != NULL);
g_return_if_fail(name != NULL);
- if (expires != -1 && time(NULL) >= expires)
+ if (expires != -1 && expires != 0 && time(NULL) >= expires)
value = NULL;
if (value != NULL) {
@@ -2023,7 +2035,7 @@ static void purple_http_cookie_jar_set_e
g_hash_table_remove(cookie_jar->tab, name);
}
-const gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar,
+gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar,
const gchar *name)
{
PurpleHttpCookie *cookie;
@@ -2035,7 +2047,7 @@ const gchar * purple_http_cookie_jar_get
if (!cookie)
return NULL;
- return cookie->value;
+ return g_strdup(purple_url_decode(cookie->value));
}
gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar)
diff --git a/libpurple/http.h b/libpurple/http.h
--- a/libpurple/http.h
+++ b/libpurple/http.h
@@ -463,9 +463,11 @@ void purple_http_cookie_jar_set(PurpleHt
*
* Gets the cookie.
*
+ * The result must be g_free'd.
+ *
* Returns: Cookie contents, or NULL, if cookie doesn't exists.
*/
-const gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar,
+gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar,
const gchar *name);
/**
diff --git a/libpurple/protocols/yahoo/ymsg.c b/libpurple/protocols/yahoo/ymsg.c
--- a/libpurple/protocols/yahoo/ymsg.c
+++ b/libpurple/protocols/yahoo/ymsg.c
@@ -1705,9 +1705,9 @@ static void yahoo_auth16_stage2(PurpleHt
"\r\n", -1);
cookiejar = purple_http_conn_get_cookie_jar(http_conn);
- yd->cookie_b = g_strdup(purple_http_cookie_jar_get(cookiejar, "B"));
- yd->cookie_t = g_strdup(purple_http_cookie_jar_get(cookiejar, "T"));
- yd->cookie_y = g_strdup(purple_http_cookie_jar_get(cookiejar, "Y"));
+ yd->cookie_b = purple_http_cookie_jar_get(cookiejar, "B");
+ yd->cookie_t = purple_http_cookie_jar_get(cookiejar, "T");
+ yd->cookie_y = purple_http_cookie_jar_get(cookiejar, "Y");
i = 0;
while (splits[i]) {
@@ -3214,7 +3214,7 @@ yahoo_login_page_got(PurpleHttpConnectio
PurpleAccount *account = purple_connection_get_account(gc);
PurpleHttpCookieJar *cjar;
GString *auth_s;
- const gchar *cookie;
+ gchar *cookie;
if (purple_http_response_get_code(resp) != 302) {
purple_connection_error(gc,
@@ -3226,14 +3226,20 @@ yahoo_login_page_got(PurpleHttpConnectio
auth_s = g_string_new(NULL);
cjar = purple_http_conn_get_cookie_jar(hc);
cookie = purple_http_cookie_jar_get(cjar, "B");
- if (cookie)
+ if (cookie) {
g_string_append_printf(auth_s, "B=%s; ", cookie);
+ g_free(cookie);
+ }
cookie = purple_http_cookie_jar_get(cjar, "T");
- if (cookie)
+ if (cookie) {
g_string_append_printf(auth_s, "T=%s; ", cookie);
+ g_free(cookie);
+ }
cookie = purple_http_cookie_jar_get(cjar, "Y");
- if (cookie)
+ if (cookie) {
g_string_append_printf(auth_s, "Y=%s; ", cookie);
+ g_free(cookie);
+ }
yd->auth = g_string_free(auth_s, FALSE);
/* Now we have our cookies to login with. I'll go get the milk. */
More information about the Commits
mailing list