[gnome-terminal] Bug 614464 - Encode any ":", "@" or "/" within the user and password field in *_proxy environment
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] Bug 614464 - Encode any ":", "@" or "/" within the user and password field in *_proxy environment
- Date: Wed, 31 Mar 2010 14:57:45 +0000 (UTC)
commit f0720f921f3e06e5773ac378fa6da78b9329972a
Author: Behdad Esfahbod <behdad behdad org>
Date: Wed Mar 31 10:56:41 2010 -0400
Bug 614464 - Encode any ":", "@" or "/" within the user and password field in *_proxy environment
Escape user/password properly.
src/terminal-util.c | 48 ++++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/src/terminal-util.c b/src/terminal-util.c
index 1a38ea5..0582a6f 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -719,47 +719,43 @@ static void
setup_http_proxy_env (GHashTable *env_table,
GConfClient *conf)
{
- gchar *host, *auth = NULL;
+ gchar *host;
gint port;
GSList *ignore;
if (!gconf_client_get_bool (conf, CONF_HTTP_PROXY_PREFIX "/use_http_proxy", NULL))
return;
- if (gconf_client_get_bool (conf, CONF_HTTP_PROXY_PREFIX "/use_authentication", NULL))
+ host = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/host");
+ port = gconf_client_get_int (conf, CONF_HTTP_PROXY_PREFIX "/port", NULL);
+ if (host && port)
{
- char *user, *password;
- user = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_user");
- password = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_password");
- if (user)
+ GString *buf = g_string_sized_new (64);
+ g_string_append (buf, "http://");
+
+ if (gconf_client_get_bool (conf, CONF_HTTP_PROXY_PREFIX "/use_authentication", NULL))
{
- if (password)
+ char *user, *password;
+ user = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_user");
+ if (user)
{
- auth = g_strdup_printf ("%s:%s", user, password);
+ g_string_append_uri_escaped (buf, user, NULL, TRUE);
+ password = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_password");
+ if (password)
+ {
+ g_string_append_c (buf, ':');
+ g_string_append_uri_escaped (buf, password, NULL, TRUE);
+ g_free (password);
+ }
g_free (user);
+ g_string_append_c (buf, '@');
}
- else
- auth = user;
}
- g_free (password);
- }
-
- host = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/host");
- port = gconf_client_get_int (conf, CONF_HTTP_PROXY_PREFIX "/port", NULL);
- if (host && port)
- {
- char *proxy;
- if (auth)
- proxy = g_strdup_printf ("http://%s %s:%d/", auth, host, port);
- else
- proxy = g_strdup_printf ("http://%s:%d/", host, port);
- set_proxy_env (env_table, "http_proxy", proxy);
+ g_string_append_printf (buf, "%s:%d/", host, port);
+ set_proxy_env (env_table, "http_proxy", g_string_free (buf, FALSE));
}
g_free (host);
- g_free (auth);
-
-
ignore = gconf_client_get_list (conf, CONF_HTTP_PROXY_PREFIX "/ignore_hosts", GCONF_VALUE_STRING, NULL);
if (ignore)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]