Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re2
Commits
5ef43bd5
Commit
5ef43bd5
authored
Mar 27, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backref() method and function always fail if the fallback is NULL,
for example if set from an unset header
parent
6271111b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
backref_fail.vtc
src/tests/backref_fail.vtc
+17
-0
vmod_re2.c
src/vmod_re2.c
+10
-4
No files found.
src/tests/backref_fail.vtc
View file @
5ef43bd5
...
...
@@ -41,6 +41,11 @@ varnish v1 -vcl+backend {
set resp.http.foo0 = barbaz.backref(0, "error0");
set resp.http.foo1 = barbaz.backref(1, "error1");
set resp.http.foo2 = barbaz.backref(2, "error2");
# Even if a match succeeded, backref() fails if
# the fallback is undefined.
set resp.http.undeffallback
= barbaz.backref(0, resp.http.undef);
}
/* match fails */
if (barbaz.match(resp.http.barf)) {
...
...
@@ -71,6 +76,9 @@ varnish v1 -vcl+backend {
set resp.http.never0 = never.backref(0, "fallback0");
set resp.http.never1 = never.backref(1, "fallback1");
set resp.http.never2 = never.backref(2, "fallback2");
/* Fallback default */
set resp.http.nofallback = never.backref(0);
}
} -start
...
...
@@ -87,6 +95,7 @@ client c1 {
expect resp.http.foo0 == "barbaz"
expect resp.http.foo1 == "bar"
expect resp.http.foo2 == "baz"
expect resp.http.undeffallback ~ "^..BACKREF (METHOD|FUNCTION) FAILED..$"
expect resp.http.puke == <undef>
expect resp.http.barf0 == "fallback0"
expect resp.http.barf1 == "fallback1"
...
...
@@ -99,6 +108,7 @@ client c1 {
expect resp.http.never0 == "fallback0"
expect resp.http.never1 == "fallback1"
expect resp.http.never2 == "fallback2"
expect resp.http.nofallback ~ "^..BACKREF (METHOD|FUNCTION) FAILED..$"
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
...
...
@@ -111,6 +121,8 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
# would have also failed due to failing prior match
expect * = VCL_Error "^vmod re2 error: frobnitz.backref.ref=3, fallback=.fallback3..: backref out of range .max 2.$"
expect * = VCL_Error "^vmod re2 error: barbaz.backref.ref=0, fallback=.<undefined>..: fallback is undefined$"
expect * = VCL_Error "^vmod re2 error: never.backref.ref=0, fallback=.fallback0..: never_capture is true for object never$"
expect * = VCL_Error "^vmod re2 error: never.backref.ref=1, fallback=.fallback1..: never_capture is true for object never$"
expect * = VCL_Error "^vmod re2 error: never.backref.ref=2, fallback=.fallback2..: never_capture is true for object never$"
...
...
@@ -235,6 +247,8 @@ varnish v1 -vcl+backend {
set resp.http.foo0 = re2.backref(0, "error0");
set resp.http.foo1 = re2.backref(1, "error1");
set resp.http.foo2 = re2.backref(2, "error2");
set resp.http.undeffallback
= re2.backref(0, resp.http.undef);
}
if (re2.match("(bar)(baz)", resp.http.barf)) {
set resp.http.puke = "match";
...
...
@@ -258,6 +272,8 @@ varnish v1 -vcl+backend {
set resp.http.never0 = re2.backref(0, "fallback0");
set resp.http.never1 = re2.backref(1, "fallback1");
set resp.http.never2 = re2.backref(2, "fallback2");
set resp.http.nofallback = re2.backref(0);
}
}
...
...
@@ -265,6 +281,7 @@ logexpect l3 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=0, fallback=.fallback..: called without previous match$"
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=3, fallback=.fallback3..: backref out of range .max 2.$"
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=0, fallback=.<undefined>..: fallback is undefined$"
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=0, fallback=.fallback0..: never_capture was true in previous match$"
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=1, fallback=.fallback1..: never_capture was true in previous match$"
expect * = VCL_Error "^vmod re2 error: re2.backref.ref=2, fallback=.fallback2..: never_capture was true in previous match$"
...
...
src/vmod_re2.c
View file @
5ef43bd5
...
...
@@ -362,8 +362,11 @@ vmod_regex_backref(VRT_CTX, struct vmod_re2_regex *re, VCL_INT refnum,
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
re
,
VMOD_RE2_REGEX_MAGIC
);
assert
(
refnum
>=
0
);
if
(
fallback
==
NULL
)
fallback
=
""
;
if
(
fallback
==
NULL
)
{
VERR
(
ctx
,
ERR_PREFIX
"fallback is undefined"
,
re
->
vcl_name
,
refnum
,
"<undefined>"
);
return
"**BACKREF METHOD FAILED**"
;
}
if
(
re
->
never_capture
)
{
VERR
(
ctx
,
ERR_PREFIX
"never_capture is true for object %s"
,
...
...
@@ -643,8 +646,11 @@ vmod_backref(VRT_CTX, struct vmod_priv *priv, VCL_INT refnum,
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
priv
);
assert
(
refnum
>=
0
);
if
(
fallback
==
NULL
)
fallback
=
""
;
if
(
fallback
==
NULL
)
{
VERR
(
ctx
,
ERR_PREFIX
"fallback is undefined"
,
refnum
,
"<undefined>"
);
return
"**BACKREF FUNCTION FAILED**"
;
}
if
(
priv
->
priv
==
NULL
)
{
VERR
(
ctx
,
ERR_PREFIX
"called without previous match"
,
refnum
,
fallback
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment