1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

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 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) Daniel (14 December 2004)
- Harshal Pradhan patched a HTTP persistent connection flaw: if the user name - Harshal Pradhan patched a HTTP persistent connection flaw: if the user name
and/or password were modified between two requests on a persistent 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: 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 modified credentials between two requests on a persistent http connection
o large file file:// resumes on Windows o large file file:// resumes on Windows
o URLs with username and IPv6 numerical addresses 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, Tim Sneddon, Ian Gulliver, Jean-Philippe Barrette-LaPierre, Jeff Phillips,
Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum, Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum,
Richard Atterer, Rene Bernhardt, Matt Veenstra, Bryan Henderson, Ton Voon, 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) 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; ++glob->size;
while (1) { while (1) {
bool skip;
switch (*pattern) { switch (*pattern) {
case '\0': /* URL ended while set was still open */ case '\0': /* URL ended while set was still open */
snprintf(glob->errormsg, sizeof(glob->errormsg), snprintf(glob->errormsg, sizeof(glob->errormsg),
@ -122,14 +124,28 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
return GLOB_ERROR; return GLOB_ERROR;
case '\\': /* escaped character, skip '\' */ case '\\': /* escaped character, skip '\' */
if (*(buf+1) == '\0') { /* but no escaping of '\0'! */ switch(pattern[1]) {
snprintf(glob->errormsg, sizeof(glob->errormsg), case '[':
"illegal pattern at pos %d\n", (int)pos); case ']':
return GLOB_ERROR; case '{':
case '}':
case ',':
skip = TRUE;
break;
default:
skip = FALSE;
break;
} }
++pattern; if(skip) {
++pos; /* intentional fallthrough */ 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: default:
*buf++ = *pattern++; /* copy character to set element */ *buf++ = *pattern++; /* copy character to set element */
++pos; ++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 \ test193 test194 test195 test196 test197 test198 test515 test516 \
test517 test518 test210 test211 test212 test220 test221 test222 \ test517 test518 test210 test211 test212 test220 test221 test222 \
test223 test224 test206 test207 test208 test209 test213 test240 \ 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 # 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 # 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>