]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: pass through [] in URLs instead of calling globbing error
authorDaniel Stenberg <daniel@haxx.se>
Fri, 3 Nov 2017 13:04:53 +0000 (15:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 4 Nov 2017 09:23:27 +0000 (10:23 +0100)
Assisted-by: Per Lundberg
Fixes #2044
Closes #2046
Closes #2048

src/tool_urlglob.c
tests/data/Makefile.inc
tests/data/test1290 [new file with mode: 0644]

index df85d7129797d3c21ce11caee475ca5aa6764ed3..f78d058cdc3302b47e5425cae267e9c5164d5994 100644 (file)
@@ -367,9 +367,11 @@ static CURLcode glob_parse(URLGlob *glob, char *pattern,
     size_t sublen = 0;
     while(*pattern && *pattern != '{') {
       if(*pattern == '[') {
-        /* Skip over potential IPv6 literals. */
-        size_t skip;
-        if(peek_ipv6(pattern, &skip)) {
+        /* skip over IPv6 literals and [] */
+        size_t skip = 0;
+        if(!peek_ipv6(pattern, &skip) && (pattern[1] == ']'))
+          skip = 2;
+        if(skip) {
           memcpy(buf, pattern, skip);
           buf += skip;
           pattern += skip;
index e3eb80e4d0e8405a4b405ba8cfae37239c9ec742..35c41a5c1ea951da8476cf36331c8d81a072612e 100644 (file)
@@ -137,7 +137,7 @@ test1252 test1253 test1254 test1255 test1256 test1257 test1258 test1259 \
 test1260 test1261 test1262 \
 \
 test1280 test1281 test1282 test1283 test1284 test1285 test1286 test1287 \
-test1288 test1289 \
+test1288 test1289 test1290 \
 test1298 test1299 \
 test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
 test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
diff --git a/tests/data/test1290 b/tests/data/test1290
new file mode 100644 (file)
index 0000000..e556303
--- /dev/null
@@ -0,0 +1,48 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+globbing
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+Verify URL globbing ignores []
+</name>
+<command>
+"http://%HOSTIP:%HTTPPORT/we/want/[]/page/1290"
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /we/want/[]/page/1290 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>