mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 12:05:06 -05:00
With CURLOPT_PROXY_TRANSFER_MODE, avoid sending invalid URLs like
ftp://example.com;type=i if the user specified ftp://example.com without the slash.
This commit is contained in:
parent
8b5102ca83
commit
10f2fa9c72
5
CHANGES
5
CHANGES
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Michal Marek (21 Aug 2009)
|
||||||
|
- With CURLOPT_PROXY_TRANSFER_MODE, avoid sending invalid URLs like
|
||||||
|
ftp://example.com;type=i if the user specified ftp://example.com without the
|
||||||
|
slash.
|
||||||
|
|
||||||
Daniel Stenberg (21 Aug 2009)
|
Daniel Stenberg (21 Aug 2009)
|
||||||
- Andre Guibert de Bruet pointed out a missing return code check for a
|
- Andre Guibert de Bruet pointed out a missing return code check for a
|
||||||
strdup() that could lead to segfault if it returned NULL. I extended his
|
strdup() that could lead to segfault if it returned NULL. I extended his
|
||||||
|
21
lib/http.c
21
lib/http.c
@ -2050,7 +2050,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
struct HTTP *http;
|
struct HTTP *http;
|
||||||
const char *ppath = data->state.path;
|
const char *ppath = data->state.path;
|
||||||
bool paste_ftp_userpwd = FALSE;
|
bool paste_ftp_userpwd = FALSE;
|
||||||
char ftp_typecode[sizeof(";type=?")] = "";
|
char ftp_typecode[sizeof("/;type=?")] = "";
|
||||||
const char *host = conn->host.name;
|
const char *host = conn->host.name;
|
||||||
const char *te = ""; /* transfer-encoding */
|
const char *te = ""; /* transfer-encoding */
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
@ -2292,21 +2292,28 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
if(checkprefix("ftp://", ppath)) {
|
if(checkprefix("ftp://", ppath)) {
|
||||||
if (data->set.proxy_transfer_mode) {
|
if (data->set.proxy_transfer_mode) {
|
||||||
/* when doing ftp, append ;type=<a|i> if not present */
|
/* when doing ftp, append ;type=<a|i> if not present */
|
||||||
char *p = strstr(ppath, ";type=");
|
char *type = strstr(ppath, ";type=");
|
||||||
if(p && p[6] && p[7] == 0) {
|
if(type && type[6] && type[7] == 0) {
|
||||||
switch (Curl_raw_toupper(p[6])) {
|
switch (Curl_raw_toupper(type[6])) {
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'I':
|
case 'I':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
p = NULL;
|
type = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!p)
|
if(!type) {
|
||||||
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
|
char *p = ftp_typecode;
|
||||||
|
/* avoid sending invalid URLs like ftp://example.com;type=i if the
|
||||||
|
* user specified ftp://example.com without the slash */
|
||||||
|
if (!*data->state.path && ppath[strlen(ppath) - 1] != '/') {
|
||||||
|
*p++ = '/';
|
||||||
|
}
|
||||||
|
snprintf(p, sizeof(ftp_typecode) - 1, ";type=%c",
|
||||||
data->set.prefer_ascii ? 'a' : 'i');
|
data->set.prefer_ascii ? 'a' : 'i');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (conn->bits.user_passwd && !conn->bits.userpwd_in_url)
|
if (conn->bits.user_passwd && !conn->bits.userpwd_in_url)
|
||||||
paste_ftp_userpwd = TRUE;
|
paste_ftp_userpwd = TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user