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
1c5b96a7
Commit
1c5b96a7
authored
Mar 27, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sub() function fails if the pattern is undefined
parent
264ce0df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
sub.vtc
src/tests/sub.vtc
+7
-0
vmod_re2.c
src/vmod_re2.c
+5
-2
No files found.
src/tests/sub.vtc
View file @
1c5b96a7
...
...
@@ -59,6 +59,10 @@ varnish v1 -vcl {
set resp.http.undeffallback = b.sub("b", "x", req.http.undef);
set resp.http.undeffallbackf
= re2.sub("b", "b", "x", req.http.undef);
# Undefined pattern in the function
set resp.http.undefpattern
= re2.sub(req.http.undef, "", "", "pattern undef");
}
} -start
...
...
@@ -93,11 +97,14 @@ client c1 {
expect resp.http.undeffallback == "**SUB METHOD FAILED**"
expect resp.http.undeffallbackf == "**SUB FUNCTION FAILED**"
expect resp.http.undefpattern == "pattern undef"
} -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 * = VCL_Error "^vmod re2 error: re2.sub.pattern=<undefined>, fallback=.pattern undef..: pattern is undefined$"
expect * = End
} -run
src/vmod_re2.c
View file @
1c5b96a7
...
...
@@ -742,8 +742,11 @@ vmod_sub(VRT_CTX, VCL_STRING pattern, VCL_STRING text, VCL_STRING rewrite,
ERR
(
ctx
,
"re2.sub(): fallback is undefined"
);
return
"**SUB FUNCTION FAILED**"
;
}
if
(
pattern
==
NULL
)
pattern
=
""
;
if
(
pattern
==
NULL
)
{
VERR
(
ctx
,
"re2.sub(pattern=<undefined>, fallback=
\"
%s
\"
): "
"pattern is undefined"
,
fallback
);
return
fallback
;
}
if
(
text
==
NULL
)
text
=
""
;
if
(
rewrite
==
NULL
)
...
...
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