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
264ce0df
Commit
264ce0df
authored
Mar 27, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sub() method and function fail if the fallback is NULL
parent
f3579552
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
sub.vtc
src/tests/sub.vtc
+15
-0
vmod_re2.c
src/vmod_re2.c
+8
-4
No files found.
src/tests/sub.vtc
View file @
264ce0df
...
...
@@ -54,6 +54,11 @@ varnish v1 -vcl {
# Match failure
set resp.http.bfail = b.sub("acd", "x", "fallbackb");
set resp.http.bfailf = re2.sub("b", "acd", "x", "fallbackf");
# Undefined fallback
set resp.http.undeffallback = b.sub("b", "x", req.http.undef);
set resp.http.undeffallbackf
= re2.sub("b", "b", "x", req.http.undef);
}
} -start
...
...
@@ -85,4 +90,14 @@ client c1 {
expect resp.http.bfail == "fallbackb"
expect resp.http.bfailf == "fallbackf"
expect resp.http.undeffallback == "**SUB METHOD FAILED**"
expect resp.http.undeffallbackf == "**SUB FUNCTION FAILED**"
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod re2 error: b.sub..: fallback is undefined$"
expect * = VCL_Error "^vmod re2 error: re2.sub..: fallback is undefined$"
expect * = End
} -run
src/vmod_re2.c
View file @
264ce0df
...
...
@@ -426,12 +426,14 @@ vmod_regex_sub(VRT_CTX, struct vmod_re2_regex *re, VCL_STRING text,
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
re
,
VMOD_RE2_REGEX_MAGIC
);
if
(
fallback
==
NULL
)
{
VERR
(
ctx
,
"%s.sub(): fallback is undefined"
,
re
->
vcl_name
);
return
"**SUB METHOD FAILED**"
;
}
if
(
text
==
NULL
)
text
=
""
;
if
(
rewrite
==
NULL
)
rewrite
=
""
;
if
(
fallback
==
NULL
)
fallback
=
""
;
return
sub
(
ctx
,
re
->
vre2
,
text
,
rewrite
,
fallback
);
}
...
...
@@ -736,14 +738,16 @@ vmod_sub(VRT_CTX, VCL_STRING pattern, VCL_STRING text, VCL_STRING rewrite,
const
char
*
ret
,
*
err
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
fallback
==
NULL
)
{
ERR
(
ctx
,
"re2.sub(): fallback is undefined"
);
return
"**SUB FUNCTION FAILED**"
;
}
if
(
pattern
==
NULL
)
pattern
=
""
;
if
(
text
==
NULL
)
text
=
""
;
if
(
rewrite
==
NULL
)
rewrite
=
""
;
if
(
fallback
==
NULL
)
fallback
=
""
;
if
((
err
=
vre2_init
(
&
vre2
,
pattern
,
utf8
,
posix_syntax
,
longest_match
,
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