Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-selector
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-selector
Commits
c71e7938
Commit
c71e7938
authored
Oct 05, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the element enum to .sub().
parent
1f071898
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
README.rst
README.rst
+3
-2
sub.vtc
src/tests/sub.vtc
+27
-0
vmod_selector.c
src/vmod_selector.c
+3
-2
vmod_selector.vcc
src/vmod_selector.vcc
+1
-0
No files found.
README.rst
View file @
c71e7938
...
...
@@ -869,8 +869,8 @@ Example::
.. _xset.sub():
STRING xset.sub(STRING str, STRING sub, BOOL all, INT n, ENUM select)
---------------------------------------------------------------------
STRING xset.sub(STRING str, STRING sub, BOOL all, INT n,
STRING element,
ENUM select)
---------------------------------------------------------------------
----------------
::
...
...
@@ -879,6 +879,7 @@ STRING xset.sub(STRING str, STRING sub, BOOL all, INT n, ENUM select)
STRING sub,
BOOL all=0,
INT n=0,
STRING element=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE
)
...
...
src/tests/sub.vtc
View file @
c71e7938
...
...
@@ -50,6 +50,13 @@ varnish v1 -vcl {
set resp.http.N-4-F = s.sub("/", client.ip, false, 4);
set resp.http.N-5-F = s.sub(client.ip, client.ip, false, 5);
set resp.http.Foo = s.sub("_barf_", "\0\0", element="foo");
set resp.http.Bar = s.sub("_barf_", "\4\3\2p", element="bar");
set resp.http.Baz = s.sub(resp.http.baz, "XXX", element="baz");
set resp.http.Quux = s.sub("/", client.ip, element="quux");
set resp.http.Foobar
= s.sub(client.ip, client.ip, element="foobar");
return (deliver);
}
} -start
...
...
@@ -79,6 +86,12 @@ client c1 {
expect resp.http.N-3-F == resp.http.N-3
expect resp.http.N-4-F == resp.http.N-4
expect resp.http.N-5-F == resp.http.N-5
expect resp.http.Foo == resp.http.N-1-1
expect resp.http.Bar == resp.http.N-2-1
expect resp.http.Baz == resp.http.N-3
expect resp.http.Quux == resp.http.N-4
expect resp.http.Foobar == resp.http.N-5
} -run
# cf. Varnish c00047.vtc, r01557.vtc, r01566.vtc
...
...
@@ -156,6 +169,10 @@ varnish v1 -vcl {
if (req.http.Suball) {
set resp.http.Suball = s.sub("foo", "bar", true);
}
if (req.http.Element) {
set resp.http.Element = s.sub("foo", "bar",
element=req.http.Element);
}
return (deliver);
}
}
...
...
@@ -175,6 +192,11 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect * = VCL_Error {^vmod selector failure: s\.sub\(\) called without prior match$}
expect * = VCL_return fail
expect * = End
expect 0 * Begin req
expect * = VCL_Error {^vmod selector failure: s\.sub\(element="oof"\): no such element$}
expect * = VCL_return fail
expect * = End
} -start
client c1 {
...
...
@@ -192,6 +214,11 @@ client c1 {
expect_close
} -run
client c1 {
txreq -hdr "Element: oof"
expect_close
} -run
logexpect l1 -wait
# Examples from the docs
...
...
src/vmod_selector.c
View file @
c71e7938
...
...
@@ -847,11 +847,12 @@ vmod_set_re_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject,
VCL_STRING
vmod_set_sub
(
VRT_CTX
,
struct
vmod_selector_set
*
set
,
VCL_STRING
str
,
VCL_STRING
sub
,
VCL_BOOL
all
,
VCL_INT
n
,
VCL_ENUM
selects
)
VCL_STRING
sub
,
VCL_BOOL
all
,
VCL_INT
n
,
VCL_STRING
element
,
VCL_ENUM
selects
)
{
vre_t
*
re
;
re
=
get_re
(
ctx
,
set
,
n
,
NULL
,
selects
,
"sub"
);
re
=
get_re
(
ctx
,
set
,
n
,
element
,
selects
,
"sub"
);
if
(
re
==
NULL
)
return
(
NULL
);
return
(
VRT_regsub
(
ctx
,
all
,
str
,
re
,
sub
));
...
...
src/vmod_selector.vcc
View file @
c71e7938
...
...
@@ -766,6 +766,7 @@ Example::
}
$Method STRING .sub(STRING str, STRING sub, BOOL all=0, INT n=0,
STRING element=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST}
select=UNIQUE)
...
...
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