fixed how backslashes are treated in glob strings

This commit is contained in:
Daniel Stenberg 2004-12-15 09:23:24 +00:00
parent f2fb9039bd
commit d88b3d3d5d
5 changed files with 76 additions and 9 deletions

View File

@ -7,6 +7,13 @@
Changelog
Daniel (15 December 2004)
- Tom Lee found out that globbing of strings with backslashes didn't work as
you'd expect. Backslashes are such a central part of windows file names that
forcing backslashes to have to be escaped with backslashes is a bit too
awkward to users. Starting now, you only need to escape globbing characters
such as the five letters: "[]{},". Added test case 214 to verify this.
Daniel (14 December 2004)
- Harshal Pradhan patched a HTTP persistent connection flaw: if the user name
and/or password were modified between two requests on a persistent

View File

@ -26,6 +26,7 @@ This release includes the following changes:
This release includes the following bugfixes:
o -T upload multiple files with backslashes in file names
o modified credentials between two requests on a persistent http connection
o large file file:// resumes on Windows
o URLs with username and IPv6 numerical addresses
@ -69,6 +70,6 @@ advice from friends like these:
Tim Sneddon, Ian Gulliver, Jean-Philippe Barrette-LaPierre, Jeff Phillips,
Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum,
Richard Atterer, Rene Bernhardt, Matt Veenstra, Bryan Henderson, Ton Voon,
Kai Sommerfeld, David Byron, Harshal Pradhan
Kai Sommerfeld, David Byron, Harshal Pradhan, Tom Lee
Thanks! (and sorry if I forgot to mention someone)

View File

@ -73,6 +73,8 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
++glob->size;
while (1) {
bool skip;
switch (*pattern) {
case '\0': /* URL ended while set was still open */
snprintf(glob->errormsg, sizeof(glob->errormsg),
@ -122,14 +124,28 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
return GLOB_ERROR;
case '\\': /* escaped character, skip '\' */
if (*(buf+1) == '\0') { /* but no escaping of '\0'! */
snprintf(glob->errormsg, sizeof(glob->errormsg),
"illegal pattern at pos %d\n", (int)pos);
return GLOB_ERROR;
switch(pattern[1]) {
case '[':
case ']':
case '{':
case '}':
case ',':
skip = TRUE;
break;
default:
skip = FALSE;
break;
}
++pattern;
++pos; /* intentional fallthrough */
if(skip) {
if (*(buf+1) == '\0') { /* but no escaping of '\0'! */
snprintf(glob->errormsg, sizeof(glob->errormsg),
"illegal pattern at pos %d\n", (int)pos);
return GLOB_ERROR;
}
++pattern;
++pos;
}
/* intentional fallthrough */
default:
*buf++ = *pattern++; /* copy character to set element */
++pos;

View File

@ -30,7 +30,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test193 test194 test195 test196 test197 test198 test515 test516 \
test517 test518 test210 test211 test212 test220 test221 test222 \
test223 test224 test206 test207 test208 test209 test213 test240 \
test241 test242 test519
test241 test242 test519 test214
# The following tests have been removed from the dist since they no longer
# work. We need to fix the test suite's FTPS server first, then bring them

43
tests/data/test214 Normal file
View File

@ -0,0 +1,43 @@
#
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
Content-Length: 6
Content-Type: text/html
Funny-head: yesyes
<foo>
</data>
</reply>
#
# Client-side
<client>
<server>
http
</server>
<name>
HTTP URL with escaped { and }
</name>
<command>
'http://%HOSTIP:%HTTPPORT/\{\}\/214'
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<strip>
^User-Agent:.*
</strip>
<protocol>
GET /{}\/214 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Pragma: no-cache
Accept: */*
</protocol>
</verify>