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
Nils Goroll
libvmod-re2
Commits
c89737b8
Commit
c89737b8
authored
Mar 27, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sub() method and function fail if the text param is NULL
parent
1c5b96a7
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
+13
-0
vmod_re2.c
src/vmod_re2.c
+10
-4
No files found.
src/tests/sub.vtc
View file @
c89737b8
...
...
@@ -63,6 +63,12 @@ varnish v1 -vcl {
# Undefined pattern in the function
set resp.http.undefpattern
= re2.sub(req.http.undef, "", "", "pattern undef");
# Undefined text
set resp.http.undeftext
= b.sub(req.http.undef, "x", "text undef");
set resp.http.undeftextf
= re2.sub("b", req.http.undef, "x", "text undef");
}
} -start
...
...
@@ -99,12 +105,19 @@ client c1 {
expect resp.http.undeffallbackf == "**SUB FUNCTION FAILED**"
expect resp.http.undefpattern == "pattern undef"
expect resp.http.undeftext == "text undef"
expect resp.http.undeftextf == "text 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 * = VCL_Error "^vmod re2 error: b.sub.text=<undefined>, fallback=.text undef..: text is undefined$"
expect * = VCL_Error "^vmod re2 error: re2.sub.pattern=.b., text=<undefined>, fallback=.text undef..: text is undefined$"
expect * = End
} -run
src/vmod_re2.c
View file @
c89737b8
...
...
@@ -430,8 +430,11 @@ vmod_regex_sub(VRT_CTX, struct vmod_re2_regex *re, VCL_STRING text,
VERR
(
ctx
,
"%s.sub(): fallback is undefined"
,
re
->
vcl_name
);
return
"**SUB METHOD FAILED**"
;
}
if
(
text
==
NULL
)
text
=
""
;
if
(
text
==
NULL
)
{
VERR
(
ctx
,
"%s.sub(text=<undefined>, fallback=
\"
%s
\"
): "
"text is undefined"
,
re
->
vcl_name
,
fallback
);
return
fallback
;
}
if
(
rewrite
==
NULL
)
rewrite
=
""
;
...
...
@@ -747,8 +750,11 @@ vmod_sub(VRT_CTX, VCL_STRING pattern, VCL_STRING text, VCL_STRING rewrite,
"pattern is undefined"
,
fallback
);
return
fallback
;
}
if
(
text
==
NULL
)
text
=
""
;
if
(
text
==
NULL
)
{
VERR
(
ctx
,
"re2.sub(pattern=
\"
%s
\"
, text=<undefined>, "
"fallback=
\"
%s
\"
): text is undefined"
,
pattern
,
fallback
);
return
fallback
;
}
if
(
rewrite
==
NULL
)
rewrite
=
""
;
...
...
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