Commit 25228a23 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

VCL regexp and regsub should treat a NULL argument as an empty

string.

Fixes	#913
parent 7ff31e98
......@@ -70,7 +70,7 @@ VRT_re_match(const char *s, void *re)
int i;
if (s == NULL)
return (0);
s = "";
AN(re);
t = re;
i = VRE_exec(t, s, strlen(s), 0, 0, NULL, 0);
......@@ -94,7 +94,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
AN(re);
if (str == NULL)
return ("");
str = "";
t = re;
memset(ovector, 0, sizeof(ovector));
i = VRE_exec(t, str, strlen(str), 0, 0, ovector, 30);
......
varnishtest "test regsub(NULL)"
server s1 {
rxreq
expect req.url == "/bar"
txresp -body "foobar"
} -start
varnish v1 -vcl+backend {
sub vcl_fetch {
if (beresp.http.bar ~ "$") {
set beresp.http.foo = regsub(beresp.http.bar, "$", "XXX");
}
}
} -start
client c1 {
txreq -url /bar
rxresp
expect resp.http.content-length == 6
expect resp.http.foo == "XXX"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment