Commit ccff2eb0 by Geoff Simmons

Backrefs fail if the fallback is undefined.

parent 701d262f
......@@ -85,6 +85,10 @@ varnish v1 -vcl {
set resp.http.bar-1 = barbaz.backref(-1, "error-1");
set resp.http.barinf
= barbaz.backref(4294967296, "errorinf");
# fallback is NULL
set resp.http.fallback
= barbaz.backref(0, req.http.undef);
}
# match fails
......@@ -125,6 +129,7 @@ client c1 -repeat 2 {
expect resp.http.bar0 == "barbaz"
expect resp.http.bar3 == "error3"
expect resp.http.barinf == "errorinf"
expect resp.http.fallback == "**BACKREF METHOD FAILED**"
expect resp.http.frob1 == "false"
expect resp.http.frob1-0 == "error0"
expect resp.http.frob1-1 == "error1"
......@@ -152,6 +157,7 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod pcre2 error: in barbaz.backref.3.: unknown substring$"
expect * = VCL_Error "^vmod pcre2 error: ref .-1. out of range in barbaz.backref.. .must be >= 0 and <= 4294967295.$"
expect * = VCL_Error "^vmod pcre2 error: ref .4294967296. out of range in barbaz.backref.. .must be >= 0 and <= 4294967295.$"
expect * = VCL_Error "^vmod pcre2 error: in barbaz.backref.0.: fallback is undefined$"
expect * = VCL_Error "^vmod pcre2 error: in frobnitz.backref.0.: no match$"
expect * = VCL_Error "^vmod pcre2 error: in frobnitz.backref.1.: no match$"
expect * = VCL_Error "^vmod pcre2 error: in frobnitz.backref.2.: no match$"
......
......@@ -533,6 +533,11 @@ vmod_regex_backref(VRT_CTX, struct vmod_pcre2_regex *regex, VCL_INT ref,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(regex, VMOD_PCRE2_REGEX_MAGIC);
if (fallback == NULL) {
VERR(ctx, "in %s.backref(%ld): fallback is undefined",
regex->vcl_name, ref);
return "**BACKREF METHOD FAILED**";
}
CHECK_UINT32_RANGE(ref, regex->vcl_name, ".backref()", fallback);
match_task = VRT_priv_task(ctx, regex);
......
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