2103
} else if ((*c=='h') && (!g_ascii_strncasecmp(c, "http://", 7) ||
2104
(!g_ascii_strncasecmp(c, "https://", 8)))) {
2107
if (badchar(*t) || badentity(t)) {
2109
if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) ||
2110
(!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) {
2114
if (*(t) == ',' && (*(t + 1) != ' ')) {
2119
if (*(t - 1) == '.')
2121
if ((*(t - 1) == ')' && (inside_paren > 0))) {
2125
url_buf = g_strndup(c, t - c);
2126
tmpurlbuf = purple_unescape_html(url_buf);
2127
g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
2128
tmpurlbuf, url_buf);
2137
} else if (!g_ascii_strncasecmp(c, "www.", 4) && (c == text || badchar(c[-1]) || badentity(c-1))) {
2141
if (badchar(*t) || badentity(t)) {
2146
if (*(t) == ',' && (*(t + 1) != ' ')) {
2151
if (*(t - 1) == '.')
2153
if ((*(t - 1) == ')' && (inside_paren > 0))) {
2156
url_buf = g_strndup(c, t - c);
2157
tmpurlbuf = purple_unescape_html(url_buf);
2158
g_string_append_printf(ret,
2159
"<A HREF=\"http://%s\">%s</A>", tmpurlbuf,
2169
} else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) {
2172
if (badchar(*t) || badentity(t)) {
2174
if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) ||
2175
(!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) {
2179
if (*(t - 1) == '.')
2181
if ((*(t - 1) == ')' && (inside_paren > 0))) {
2184
url_buf = g_strndup(c, t - c);
2185
tmpurlbuf = purple_unescape_html(url_buf);
2186
g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
2187
tmpurlbuf, url_buf);
2198
} else if (!g_ascii_strncasecmp(c, "ftp.", 4) && (c == text || badchar(c[-1]) || badentity(c-1))) {
2202
if (badchar(*t) || badentity(t)) {
2206
if (*(t - 1) == '.')
2208
if ((*(t - 1) == ')' && (inside_paren > 0))) {
2211
url_buf = g_strndup(c, t - c);
2212
tmpurlbuf = purple_unescape_html(url_buf);
2213
g_string_append_printf(ret,
2214
"<A HREF=\"ftp://%s\">%s</A>", tmpurlbuf,
2144
} else if (!g_ascii_strncasecmp(c, "http://", 7)) {
2145
c = process_link(ret, text, c, 7, "", inside_paren);
2146
} else if (!g_ascii_strncasecmp(c, "https://", 8)) {
2147
c = process_link(ret, text, c, 8, "", inside_paren);
2148
} else if (!g_ascii_strncasecmp(c, "ftp://", 6)) {
2149
c = process_link(ret, text, c, 6, "", inside_paren);
2150
} else if (!g_ascii_strncasecmp(c, "sftp://", 7)) {
2151
c = process_link(ret, text, c, 7, "", inside_paren);
2152
} else if (!g_ascii_strncasecmp(c, "file://", 7)) {
2153
c = process_link(ret, text, c, 7, "", inside_paren);
2154
} else if (!g_ascii_strncasecmp(c, "www.", 4) && c[4] != '.' && (c == text || badchar(c[-1]) || badentity(c-1))) {
2155
c = process_link(ret, text, c, 4, "http://", inside_paren);
2156
} else if (!g_ascii_strncasecmp(c, "ftp.", 4) && c[4] != '.' && (c == text || badchar(c[-1]) || badentity(c-1))) {
2157
c = process_link(ret, text, c, 4, "ftp://", inside_paren);
2158
} else if (!g_ascii_strncasecmp(c, "xmpp:", 5) && (c == text || badchar(c[-1]) || badentity(c-1))) {
2159
c = process_link(ret, text, c, 5, "", inside_paren);
2226
2160
} else if (!g_ascii_strncasecmp(c, "mailto:", 7)) {
3557
3456
/* Only care about @ char BEFORE the first / */
3558
3457
at = strchr(url, '@');
3559
3458
slash = strchr(url, '/');
3561
(((slash != NULL) && (strlen(at) > strlen(slash))) ||
3563
g_snprintf(scan_info, sizeof(scan_info),
3564
"%%255[%s]:%%255[%s]^@", user_ctrl, passwd_ctrl);
3460
if (at && (!slash || at < slash)) {
3461
scan_info = "%255[" USER_CTRL "]:%255[" PASSWD_CTRL "]^@";
3565
3462
f = sscanf(url, scan_info, user, passwd);
3568
3465
/* No passwd, possibly just username supplied */
3569
g_snprintf(scan_info, sizeof(scan_info),
3570
"%%255[%s]^@", user_ctrl);
3466
scan_info = "%255[" USER_CTRL "]^@";
3571
3467
f = sscanf(url, scan_info, user);
3575
3470
url = at+1; /* move pointer after the @ char */
3578
3475
*passwd = '\0';
3581
g_snprintf(scan_info, sizeof(scan_info),
3582
"%%255[%s]:%%5[%s]/%%255[%s]", addr_ctrl, port_ctrl, page_ctrl);
3479
scan_info = "%255[" ADDR_CTRL "]:%5[" PORT_CTRL "]/%255[" PAGE_CTRL "]";
3584
3480
f = sscanf(url, scan_info, host, port_str, path);
3588
g_snprintf(scan_info, sizeof(scan_info),
3589
"%%255[%s]/%%255[%s]",
3590
addr_ctrl, page_ctrl);
3484
scan_info = "%255[" ADDR_CTRL "]/%255[" PAGE_CTRL "]";
3591
3485
f = sscanf(url, scan_info, host, path);
3592
3486
/* Use the default port */
3724
3624
if (purple_strcasestr(new_url, "https://") != NULL) {
3725
3625
gfud->is_ssl = TRUE;
3726
gfud->ssl_connection = purple_ssl_connect(NULL,
3626
gfud->ssl_connection = purple_ssl_connect(gfud->account,
3727
3627
gfud->website.address, gfud->website.port,
3728
3628
ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud);
3730
gfud->connect_data = purple_proxy_connect(NULL, NULL,
3630
gfud->connect_data = purple_proxy_connect(NULL, gfud->account,
3731
3631
gfud->website.address, gfud->website.port,
3732
3632
url_fetch_connect_cb, gfud);
4022
if (gfud->request == NULL)
3922
if (gfud->request == NULL) {
3924
PurpleProxyInfo *gpi = purple_proxy_get_setup(gfud->account);
3925
GString *request_str = g_string_new(NULL);
3927
g_string_append_printf(request_str, "GET %s%s HTTP/%s\r\n"
3928
"Connection: close\r\n",
3929
(gfud->full ? "" : "/"),
3930
(gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")),
3931
(gfud->http11 ? "1.1" : "1.0"));
3933
if (gfud->user_agent)
3934
g_string_append_printf(request_str, "User-Agent: %s\r\n", gfud->user_agent);
4024
3936
/* Host header is not forbidden in HTTP/1.0 requests, and HTTP/1.1
4025
3937
* clients must know how to handle the "chunked" transfer encoding.
4026
3938
* Purple doesn't know how to handle "chunked", so should always send
4027
3939
* the Host header regardless, to get around some observed problems
4029
if (gfud->user_agent) {
4030
gfud->request = g_strdup_printf(
4031
"GET %s%s HTTP/%s\r\n"
4032
"Connection: close\r\n"
4033
"User-Agent: %s\r\n"
4036
(gfud->full ? "" : "/"),
4037
(gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")),
4038
(gfud->http11 ? "1.1" : "1.0"),
4039
(gfud->user_agent ? gfud->user_agent : ""),
4040
(gfud->website.address ? gfud->website.address : ""));
4042
gfud->request = g_strdup_printf(
4043
"GET %s%s HTTP/%s\r\n"
4044
"Connection: close\r\n"
4047
(gfud->full ? "" : "/"),
4048
(gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")),
4049
(gfud->http11 ? "1.1" : "1.0"),
4050
(gfud->website.address ? gfud->website.address : ""));
3941
g_string_append_printf(request_str, "Accept: */*\r\n"
3943
(gfud->website.address ? gfud->website.address : ""));
3945
if (purple_proxy_info_get_username(gpi) != NULL
3946
&& (purple_proxy_info_get_type(gpi) == PURPLE_PROXY_USE_ENVVAR
3947
|| purple_proxy_info_get_type(gpi) == PURPLE_PROXY_HTTP)) {
3948
/* This chunk of code was copied from proxy.c http_start_connect_tunneling()
3949
* This is really a temporary hack - we need a more complete proxy handling solution,
3950
* so I didn't think it was worthwhile to refactor for reuse
3952
char *t1, *t2, *ntlm_type1;
3956
ret = gethostname(hostname, sizeof(hostname));
3957
hostname[sizeof(hostname) - 1] = '\0';
3958
if (ret < 0 || hostname[0] == '\0') {
3959
purple_debug_warning("util", "proxy - gethostname() failed -- is your hostname set?");
3960
strcpy(hostname, "localhost");
3963
t1 = g_strdup_printf("%s:%s",
3964
purple_proxy_info_get_username(gpi),
3965
purple_proxy_info_get_password(gpi) ?
3966
purple_proxy_info_get_password(gpi) : "");
3967
t2 = purple_base64_encode((const guchar *)t1, strlen(t1));
3970
ntlm_type1 = purple_ntlm_gen_type1(hostname, "");
3972
g_string_append_printf(request_str,
3973
"Proxy-Authorization: Basic %s\r\n"
3974
"Proxy-Authorization: NTLM %s\r\n"
3975
"Proxy-Connection: Keep-Alive\r\n",
3981
g_string_append(request_str, "\r\n");
3983
gfud->request = g_string_free(request_str, FALSE);
4054
3986
if(purple_debug_is_unsafe())