| 550 if (purple_proxy_info_get_proxy_type(gpi) == PURPLE_PROXY_USE_ENVVAR) { |
550 if (purple_proxy_info_get_proxy_type(gpi) == PURPLE_PROXY_USE_ENVVAR) { |
| 551 if ((tmp = g_getenv("HTTP_PROXY")) != NULL || |
551 if ((tmp = g_getenv("HTTP_PROXY")) != NULL || |
| 552 (tmp = g_getenv("http_proxy")) != NULL || |
552 (tmp = g_getenv("http_proxy")) != NULL || |
| 553 (tmp = g_getenv("HTTPPROXY")) != NULL) |
553 (tmp = g_getenv("HTTPPROXY")) != NULL) |
| 554 { |
554 { |
| 555 SoupURI *url; |
555 gchar *scheme, *host, *username, *password; |
| |
556 gint port; |
| |
557 GError *error = NULL; |
| 556 |
558 |
| 557 /* http_proxy-format: |
559 /* http_proxy-format: |
| 558 * export http_proxy="http://user:passwd@your.proxy.server:port/" |
560 * export http_proxy="http://user:passwd@your.proxy.server:port/" |
| 559 */ |
561 */ |
| 560 url = soup_uri_new(tmp); |
562 if (!g_uri_split_with_user(tmp, G_URI_FLAGS_HAS_PASSWORD, &scheme, |
| 561 if (!SOUP_URI_VALID_FOR_HTTP(url)) { |
563 &username, &password, NULL, |
| 562 purple_debug_warning("proxy", "Couldn't parse URL: %s", tmp); |
564 &host, &port, NULL, NULL, NULL, &error)) |
| |
565 { |
| |
566 purple_debug_warning("proxy", "Couldn't parse URL: %s: %s", tmp, error->message); |
| |
567 g_error_free(error); |
| 563 return gpi; |
568 return gpi; |
| 564 } |
569 } |
| 565 |
570 if (!purple_strequal(scheme, "http")) { |
| 566 purple_proxy_info_set_host(gpi, url->host); |
571 purple_debug_warning("proxy", "Couldn't parse URL: %s", tmp); |
| 567 purple_proxy_info_set_username(gpi, url->user); |
572 g_free(username); |
| 568 purple_proxy_info_set_password(gpi, url->password); |
573 g_free(password); |
| 569 purple_proxy_info_set_port(gpi, url->port); |
574 g_free(host); |
| 570 |
575 return gpi; |
| 571 soup_uri_free(url); |
576 } |
| |
577 |
| |
578 purple_proxy_info_set_host(gpi, host); |
| |
579 purple_proxy_info_set_username(gpi, username); |
| |
580 purple_proxy_info_set_password(gpi, password); |
| |
581 purple_proxy_info_set_port(gpi, port); |
| |
582 |
| |
583 g_free(host); |
| |
584 g_free(username); |
| |
585 g_free(password); |
| 572 |
586 |
| 573 /* XXX: Do we want to skip this step if user/password/port were part of url? */ |
587 /* XXX: Do we want to skip this step if user/password/port were part of url? */ |
| 574 if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL || |
588 if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL || |
| 575 (tmp = g_getenv("http_proxy_user")) != NULL || |
589 (tmp = g_getenv("http_proxy_user")) != NULL || |
| 576 (tmp = g_getenv("HTTPPROXYUSER")) != NULL) |
590 (tmp = g_getenv("HTTPPROXYUSER")) != NULL) |