fixed how backslashes are treated in glob strings
authorDaniel Stenberg <daniel@haxx.se>
Wed, 15 Dec 2004 09:23:24 +0000 (09:23 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 15 Dec 2004 09:23:24 +0000 (09:23 +0000)
CHANGES
RELEASE-NOTES
src/urlglob.c
tests/data/Makefile.am
tests/data/test214 [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index aa65402..c77f06f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index b40664a..80825dc 100644 (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)
index e4f441b..64d7007 100644 (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;
index ca04cfe..3e86602 100644 (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
diff --git a/tests/data/test214 b/tests/data/test214
new file mode 100644 (file)
index 0000000..8a7405b
--- /dev/null
@@ -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\r
+Host: %HOSTIP:%HTTPPORT\r
+Pragma: no-cache\r
+Accept: */*\r
+\r
+</protocol>
+
+</verify>