Commit 98cf8943 authored by Geoff Simmons's avatar Geoff Simmons

If the match subject is NULL, then match as if it is the empty string.

For compatibility with native VCL regexen.
parent d9c78b70
......@@ -83,45 +83,6 @@ client c1 -repeat 2 {
expect resp.http.bar1 == "2"
} -run
# server s1 -wait
# server s1 -repeat 2 {
# rxreq
# txresp -body "foobar"
# } -start
# varnish v1 -vcl+backend {
# import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
# sub vcl_init {
# new end = pcre2.regex("$");
# new empty = pcre2.regex("");
# }
# sub vcl_backend_response {
# if (beresp.http.bar ~ "$") {
# set beresp.http.foo-native = "XXX";
# }
# if (beresp.http.foo ~ "") {
# set beresp.http.bar-native = "YYY";
# }
# if (end.match(beresp.http.bar)) {
# set beresp.http.foo = "XXX";
# }
# if (empty.match(beresp.http.foo)) {
# set beresp.http.bar = "YYY";
# }
# }
# }
# client c1 -repeat 2 {
# txreq
# rxresp
# expect resp.status == 200
# expect resp.http.foo == "XXX"
# expect resp.http.bar == "YYY"
# } -run
# test matches from pcre2 testinput1
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
......
# looks like -*- vcl -*-
varnishtest "match null subjects"
# Confirm that if the subject is NULL, for example when set from an
# unset header, it is matched as if it is the empty string. For
# compatibility with native VCL regexen.
# cf. varnish r00913.vtc
server s1 -repeat 2 {
rxreq
txresp -body "foobar"
} -start
varnish v1 -vcl+backend {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
sub vcl_init {
new end = pcre2.regex("$");
new empty = pcre2.regex("");
}
sub vcl_backend_response {
if (beresp.http.bar ~ "$") {
set beresp.http.foo-native = "XXX";
}
if (beresp.http.foo ~ "") {
set beresp.http.bar-native = "YYY";
}
if (end.match(beresp.http.bar)) {
set beresp.http.foo = "XXX";
}
if (empty.match(beresp.http.foo)) {
set beresp.http.bar = "YYY";
}
}
} -start
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == 200
expect resp.http.foo-native == "XXX"
expect resp.http.bar-native == "YYY"
expect resp.http.foo == "XXX"
expect resp.http.bar == "YYY"
} -run
......@@ -403,10 +403,8 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex,
CHECK_OBJ_NOTNULL(regex, VMOD_PCRE2_REGEX_MAGIC);
AN(gctx_task);
AN(mctx_call);
if (subject == NULL) {
VERR(ctx, "subject is NULL in %s.match()", regex->vcl_name);
return 0;
}
if (subject == NULL)
subject = "";
/*
* The general context is task-scoped and shared by all objects
......
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