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
4de7fa5a
Commit
4de7fa5a
authored
Mar 27, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function match() fails if the regex is NULL
parent
5ef43bd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
match.vtc
src/tests/match.vtc
+30
-1
vmod_re2.c
src/vmod_re2.c
+7
-2
No files found.
src/tests/match.vtc
View file @
4de7fa5a
# looks like -*- vcl -*-
# looks like -*- vcl -*-
varnishtest "regexp match and no-match
(cf. varnish b00028.vtc)
"
varnishtest "regexp match and no-match"
server s1 {
server s1 {
rxreq
rxreq
txresp -hdr "Foo: bar" -hdr "Bar: foo" -body "1111\n"
txresp -hdr "Foo: bar" -hdr "Bar: foo" -body "1111\n"
} -start
} -start
# cf. varnish b00028.vtc
varnish v1 -vcl+backend {
varnish v1 -vcl+backend {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
...
@@ -68,3 +69,31 @@ client c1 {
...
@@ -68,3 +69,31 @@ client c1 {
expect resp.http.foo1s == "1"
expect resp.http.foo1s == "1"
expect resp.http.bar1s == "2"
expect resp.http.bar1s == "2"
} -run
} -run
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (re2.match(req.http.undef, "")) {
set resp.http.undef = "match";
}
}
}
client c2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.undef == <undef>
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod re2 error: re2.match.pattern=.<undefined>., text=...: pattern is undefined$"
expect * = End
} -run
src/vmod_re2.c
View file @
4de7fa5a
...
@@ -596,8 +596,13 @@ vmod_match(VRT_CTX, struct vmod_priv *priv, VCL_STRING pattern,
...
@@ -596,8 +596,13 @@ vmod_match(VRT_CTX, struct vmod_priv *priv, VCL_STRING pattern,
int
ngroups
=
0
;
int
ngroups
=
0
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
pattern
==
NULL
)
if
(
subject
==
NULL
)
pattern
=
""
;
subject
=
""
;
if
(
pattern
==
NULL
)
{
VERR
(
ctx
,
ERR_PREFIX
"pattern is undefined"
,
"<undefined>"
,
subject
);
return
0
;
}
if
((
err
=
vre2_init
(
&
vre2
,
pattern
,
utf8
,
posix_syntax
,
longest_match
,
if
((
err
=
vre2_init
(
&
vre2
,
pattern
,
utf8
,
posix_syntax
,
longest_match
,
max_mem
,
literal
,
never_nl
,
dot_nl
,
never_capture
,
max_mem
,
literal
,
never_nl
,
dot_nl
,
never_capture
,
...
...
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