diff --git a/lib/dict.c b/lib/dict.c index b326054d1bf7c0f13b4ce334172be303762f33c8..0fad32bfa5f9c12c553c4a7a898326efdf34a822 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -98,7 +98,7 @@ const struct Curl_handler Curl_handler_dict = { ZERO_NULL, /* readwrite */ PORT_DICT, /* defport */ CURLPROTO_DICT, /* protocol */ - PROTOPT_NONE /* flags */ + PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */ }; static char *unescape_word(struct SessionHandle *data, const char *inputbuff) diff --git a/lib/file.c b/lib/file.c index 9421c445b0e0ea0d41f49ca8fdb9dfc0d2b9d703..4447c73f6852281153af001b2e413b5bc89f5f15 100644 --- a/lib/file.c +++ b/lib/file.c @@ -119,7 +119,7 @@ const struct Curl_handler Curl_handler_file = { ZERO_NULL, /* readwrite */ 0, /* defport */ CURLPROTO_FILE, /* protocol */ - PROTOPT_NONETWORK /* flags */ + PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */ }; diff --git a/lib/ftp.c b/lib/ftp.c index e5b1682fcb943746d7260465bc4c6b9de7a38d79..05f6f450f8e5cc810907d2c7c868aa335e8828a7 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -178,7 +178,8 @@ const struct Curl_handler Curl_handler_ftp = { ZERO_NULL, /* readwrite */ PORT_FTP, /* defport */ CURLPROTO_FTP, /* protocol */ - PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ + PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD + | PROTOPT_NOURLQUERY /* flags */ }; @@ -205,7 +206,7 @@ const struct Curl_handler Curl_handler_ftps = { PORT_FTPS, /* defport */ CURLPROTO_FTP | CURLPROTO_FTPS, /* protocol */ PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION | - PROTOPT_NEEDSPWD /* flags */ + PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY /* flags */ }; #endif diff --git a/lib/imap.c b/lib/imap.c index ab53c9d74bdb1b8163c06544280d598afa6a860b..c98730cb591efcd8f3d17434ff7f42147019fa2c 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -125,7 +125,8 @@ const struct Curl_handler Curl_handler_imap = { ZERO_NULL, /* readwrite */ PORT_IMAP, /* defport */ CURLPROTO_IMAP, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD + | PROTOPT_NOURLQUERY /* flags */ }; @@ -151,7 +152,8 @@ const struct Curl_handler Curl_handler_imaps = { ZERO_NULL, /* readwrite */ PORT_IMAPS, /* defport */ CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_SSL | PROTOPT_NEEDSPWD /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL | PROTOPT_NEEDSPWD + | PROTOPT_NOURLQUERY /* flags */ }; #endif diff --git a/lib/pop3.c b/lib/pop3.c index 6cda3bc5aa76c9bd9feecb716df0940815bc4447..8fd8ab01f517eb0af57b751b10784b62418ae8fa 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -125,7 +125,7 @@ const struct Curl_handler Curl_handler_pop3 = { ZERO_NULL, /* readwrite */ PORT_POP3, /* defport */ CURLPROTO_POP3, /* protocol */ - PROTOPT_CLOSEACTION /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */ }; @@ -151,7 +151,8 @@ const struct Curl_handler Curl_handler_pop3s = { ZERO_NULL, /* readwrite */ PORT_POP3S, /* defport */ CURLPROTO_POP3 | CURLPROTO_POP3S, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL + | PROTOPT_NOURLQUERY /* flags */ }; #endif diff --git a/lib/smtp.c b/lib/smtp.c index ea6bafaf803646935b74ccbc0f52e16a7502579b..7512f1d0a42d8e3efb7644880c4810fa3c41578a 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -133,7 +133,7 @@ const struct Curl_handler Curl_handler_smtp = { ZERO_NULL, /* readwrite */ PORT_SMTP, /* defport */ CURLPROTO_SMTP, /* protocol */ - PROTOPT_CLOSEACTION /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */ }; #ifdef USE_SSL @@ -158,7 +158,8 @@ const struct Curl_handler Curl_handler_smtps = { ZERO_NULL, /* readwrite */ PORT_SMTPS, /* defport */ CURLPROTO_SMTP | CURLPROTO_SMTPS, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL + | PROTOPT_NOURLQUERY /* flags */ }; #endif diff --git a/lib/ssh.c b/lib/ssh.c index 410f3973060cef6996f960ef2eb6e8f5f9184a6d..91aa4406247578ef794a7c1689ee86ea582953d0 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -171,7 +171,8 @@ const struct Curl_handler Curl_handler_scp = { ZERO_NULL, /* readwrite */ PORT_SSH, /* defport */ CURLPROTO_SCP, /* protocol */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION + | PROTOPT_NOURLQUERY /* flags */ }; @@ -196,7 +197,8 @@ const struct Curl_handler Curl_handler_sftp = { ZERO_NULL, /* readwrite */ PORT_SSH, /* defport */ CURLPROTO_SFTP, /* protocol */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION + | PROTOPT_NOURLQUERY /* flags */ }; diff --git a/lib/telnet.c b/lib/telnet.c index 59094b6740ba320c0974fe74fff1ca9f234ad8e3..bbad08de1939994d411d4df446d7c22052f100ff 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -188,7 +188,7 @@ const struct Curl_handler Curl_handler_telnet = { ZERO_NULL, /* readwrite */ PORT_TELNET, /* defport */ CURLPROTO_TELNET, /* protocol */ - PROTOPT_NONE /* flags */ + PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */ }; diff --git a/lib/tftp.c b/lib/tftp.c index 9b44a9b3dfe6ecddc4af23d0c214c7fe180adf9e..370665a43348d9e5f7f4b27d4017ab263e69f255 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -190,7 +190,7 @@ const struct Curl_handler Curl_handler_tftp = { ZERO_NULL, /* readwrite */ PORT_TFTP, /* defport */ CURLPROTO_TFTP, /* protocol */ - PROTOPT_NONE /* flags */ + PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */ }; /********************************************************** diff --git a/lib/url.c b/lib/url.c index 517dc18da2f5a6057d5d098050ebe67a35c46243..2c5cb39b843c39ea9ccf16829bfb0b3df852d27c 100644 --- a/lib/url.c +++ b/lib/url.c @@ -4824,6 +4824,25 @@ static CURLcode create_conn(struct SessionHandle *data, if(result != CURLE_OK) return result; + + /************************************************************* + * If the protocol can't handle url query strings, then cut + * of the unhandable part + *************************************************************/ + if((conn->given->flags&PROTOPT_NOURLQUERY)) { + char *path_q_sep = strchr(conn->data->state.path, '?'); + if(path_q_sep) { + /* according to rfc3986, allow the query (?foo=bar) + also on protocols that can't handle it. + + cut the string-part after '?' + */ + + /* terminate the string */ + path_q_sep[0] = 0; + } + } + #ifndef CURL_DISABLE_PROXY /************************************************************* * Extract the user and password from the authentication string diff --git a/lib/urldata.h b/lib/urldata.h index 3e7db2525c9f0b5ae57e78c2159c19356bcaa0cf..55f0a7b851ae5d41aeb3cfa92671c7e4f50acf76 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -713,6 +713,8 @@ struct Curl_handler { #define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */ #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it gets a default */ +#define PROTOPT_NOURLQUERY (1<<6) /* protocol can't handle + url query strings (?foo=bar) ! */ /* return the count of bytes sent, or -1 on error */ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index c52ef243c6f81f7d755ad4fef608944766068ec1..2d86aa12c88eee959af3d58783af7da9b9ee59ae 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -78,6 +78,7 @@ test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \ test1126 test1127 test1128 test1129 test1130 test1131 \ test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \ test1208 test1209 test1210 \ +test1220 \ test1300 test1301 test1302 test1303 test1304 test1305 \ test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \ test1314 \ diff --git a/tests/data/test1220 b/tests/data/test1220 new file mode 100644 index 0000000000000000000000000000000000000000..d365249601cb154016d18771d2a3277cb8657d8c --- /dev/null +++ b/tests/data/test1220 @@ -0,0 +1,30 @@ +<testcase> +# Server-side +<reply> +<data> +</data> +</reply> + +# Client-side +<client> +<server> +file +</server> + <name> +file:// URLs with query string + </name> + <command> +file://localhost/%PWD/log/test1220.txt?a_query=foobar#afragment +</command> +<file name="log/test1220.txt"> +contents in a single file +</file> +</client> + +# Verify data after the test has been "shot" +<verify> +<stdout> +contents in a single file +</stdout> +</verify> +</testcase>