[master] 896c923 More comprehensive implementation of ARGV_NOESC

Poul-Henning Kamp phk at varnish-cache.org
Wed May 18 11:38:17 CEST 2011


commit 896c923fb270466ee910102240cf2f9e2e31994f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed May 18 09:37:23 2011 +0000

    More comprehensive implementation of ARGV_NOESC

diff --git a/lib/libvarnish/argv.c b/lib/libvarnish/argv.c
index d8fefa2..7fbf95c 100644
--- a/lib/libvarnish/argv.c
+++ b/lib/libvarnish/argv.c
@@ -154,7 +154,7 @@ ParseArgv(const char *s, int *argc, int flag)
 		}
 		if ((flag & ARGV_COMMENT) && *s == '#')
 			break;
-		if (*s == '"') {
+		if (*s == '"' && !(flag & ARGV_NOESC)) {
 			p = ++s;
 			quote = 1;
 		} else {
@@ -179,7 +179,7 @@ ParseArgv(const char *s, int *argc, int flag)
 				s++;
 				continue;
 			}
-			if (*s == '"')
+			if (*s == '"' && !(flag & ARGV_NOESC))
 				break;
 			if (*s == '\0') {
 				argv[0] = err_missing_quote;
@@ -191,7 +191,15 @@ ParseArgv(const char *s, int *argc, int flag)
 			argv = realloc(argv, sizeof (*argv) * (largv += largv));
 			assert(argv != NULL);
 		}
-		argv[nargv++] = BackSlashDecode(p, s);
+		if (flag & ARGV_NOESC) {
+			argv[nargv] = malloc(1 + (s - p));
+			assert(argv[nargv] != NULL);
+			memcpy(argv[nargv], p, s - p);
+			argv[nargv][s - p] = '\0';
+			nargv++;
+		} else {
+			argv[nargv++] = BackSlashDecode(p, s);
+		}
 		if (*s != '\0')
 			s++;
 	}



More information about the varnish-commit mailing list