Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
ecad74be
Commit
ecad74be
authored
Oct 12, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework the filter-list parsing and test a couple of corner cases.
parent
e8276b9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
27 deletions
+77
-27
cache_vrt_filter.c
bin/varnishd/cache/cache_vrt_filter.c
+40
-26
m00048.vtc
bin/varnishtest/tests/m00048.vtc
+37
-1
No files found.
bin/varnishd/cache/cache_vrt_filter.c
View file @
ecad74be
...
...
@@ -150,43 +150,57 @@ VRT_RemoveVDP(VRT_CTX, const struct vdp *filter)
FREE_OBJ
(
vp
);
}
static
const
struct
vfilter
vfilter_error
[
1
];
static
const
struct
vfilter
*
vcl_filter_list_iter
(
const
struct
vfilter_head
*
h1
,
const
struct
vfilter_head
*
h2
,
const
char
**
flp
)
{
const
char
*
fl
,
*
q
;
const
struct
vfilter
*
vp
;
AN
(
h1
);
AN
(
h2
);
AN
(
flp
);
fl
=
*
flp
;
AN
(
fl
);
while
(
vct_isspace
(
*
fl
))
fl
++
;
if
(
*
fl
==
'\0'
)
{
*
flp
=
NULL
;
return
(
NULL
);
}
for
(
q
=
fl
;
*
q
&&
!
vct_isspace
(
*
q
);
q
++
)
continue
;
*
flp
=
q
;
VTAILQ_FOREACH
(
vp
,
h1
,
list
)
if
(
vp
->
nlen
==
q
-
fl
&&
!
memcmp
(
fl
,
vp
->
name
,
vp
->
nlen
))
return
(
vp
);
VTAILQ_FOREACH
(
vp
,
h2
,
list
)
if
(
vp
->
nlen
==
q
-
fl
&&
!
memcmp
(
fl
,
vp
->
name
,
vp
->
nlen
))
return
(
vp
);
*
flp
=
fl
;
return
(
vfilter_error
);
}
int
VCL_StackVFP
(
struct
vfp_ctx
*
vc
,
const
struct
vcl
*
vcl
,
const
char
*
fl
)
{
const
char
*
p
,
*
q
;
const
struct
vfilter
*
vp
;
VSLb
(
vc
->
wrk
->
vsl
,
SLT_Filters
,
"%s"
,
fl
);
for
(
p
=
fl
;
*
p
;
p
=
q
)
{
if
(
vct_isspace
(
*
p
))
{
q
=
p
+
1
;
continue
;
}
for
(
q
=
p
;
*
q
;
q
++
)
if
(
vct_isspace
(
*
q
))
break
;
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
if
(
vp
->
nlen
!=
q
-
p
)
continue
;
if
(
!
memcmp
(
p
,
vp
->
name
,
vp
->
nlen
))
break
;
}
if
(
vp
==
NULL
)
{
VTAILQ_FOREACH
(
vp
,
&
vcl
->
vfps
,
list
)
{
if
(
vp
->
nlen
!=
q
-
p
)
continue
;
if
(
!
memcmp
(
p
,
vp
->
name
,
vp
->
nlen
))
break
;
}
}
while
(
1
)
{
vp
=
vcl_filter_list_iter
(
&
vfp_filters
,
&
vcl
->
vfps
,
&
fl
);
if
(
vp
==
NULL
)
return
(
VFP_Error
(
vc
,
"Filter '%.*s' not found"
,
(
int
)(
q
-
p
),
p
));
return
(
0
);
if
(
vp
==
vfilter_error
)
return
(
VFP_Error
(
vc
,
"Filter '...%s' not found"
,
fl
));
if
(
VFP_Push
(
vc
,
vp
->
vfp
)
==
NULL
)
return
(
-
1
);
}
return
(
0
);
}
void
...
...
bin/varnishtest/tests/m00048.vtc
View file @
ecad74be
...
...
@@ -3,6 +3,11 @@ varnishtest "VMOD vfp"
server s1 {
rxreq
txresp -body "Ponto Facto, Caesar Transit!"
rxreq
txresp -body "Ponto Facto, Caesar Transit!"
accept
rxreq
txresp -body "Ponto Facto, Caesar Transit!"
} -start
varnish v1 -vcl+backend {
...
...
@@ -14,8 +19,39 @@ varnish v1 -vcl+backend {
} -start
client c1 {
txreq
txreq
-hdr "Cookie: a"
rxresp
expect resp.body == "Cbagb Snpgb, Pnrfne Genafvg!"
} -run
varnish v1 -vsl_catchup
varnish v1 -vcl+backend {
import debug;
sub vcl_backend_response {
set beresp.filters = "rot13 rot13a";
}
}
client c1 {
txreq -hdr "Cookie: a"
rxresp
expect resp.status == 503
} -run
varnish v1 -vcl+backend {
import debug;
sub vcl_backend_response {
set beresp.filters = "rot13 rot14";
}
}
client c1 {
txreq -hdr "Cookie: a"
rxresp
expect resp.status == 503
} -run
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