From: phk Date: Sun, 18 Jan 2009 14:54:41 +0000 (+0000) Subject: Properly quote the ban descriptions. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03fc3dcce5313e10e586f861c3a4f44a08b5a048;p=varnish Properly quote the ban descriptions. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3516 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index 1c0466d8..f97a571b 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -215,6 +215,7 @@ ban_parse_test(struct cli *cli, struct ban *b, const char *a1, const char *a2, c { struct ban_test *bt; char buf[512]; + struct vsb *sb; int i; CHECK_OBJ_NOTNULL(b, BAN_MAGIC); @@ -253,8 +254,15 @@ ban_parse_test(struct cli *cli, struct ban *b, const char *a1, const char *a2, c } /* XXX: proper quoting */ - asprintf(&bt->test, "%s %s \"%s\"", a1, a2, a3); - + sb = vsb_newauto(); + XXXAN(sb); + vsb_printf(sb, "%s %s ", a1, a2); + vsb_quote(sb, a3, 0); + vsb_finish(sb); + AZ(vsb_overflowed(sb)); + bt->test = strdup(vsb_data(sb)); + XXXAN(bt->test); + vsb_delete(sb); return (0); } diff --git a/varnish-cache/bin/varnishtest/tests/c00021.vtc b/varnish-cache/bin/varnishtest/tests/c00021.vtc index a222c87f..e4e305d0 100644 --- a/varnish-cache/bin/varnishtest/tests/c00021.vtc +++ b/varnish-cache/bin/varnishtest/tests/c00021.vtc @@ -28,8 +28,8 @@ varnish v1 -clierr 104 "purge foo bar" varnish v1 -clierr 106 "purge a b c && a" varnish v1 -clierr 106 "purge a b c && a b" varnish v1 -clierr 106 "purge a b c || a b c" -varnish v1 -cli "purge req.url ~ foo" -# varnish v1 -cli "purge req.url ~ foo && req.url ~ bar" +varnish v1 -cliok "purge req.url ~ foo && req.url ~ \"[ o]\"" +varnish v1 -cliok "purge.list" client c1 { txreq -url "/foo"