Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re
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-re
Commits
33f47f4c
Commit
33f47f4c
authored
Sep 12, 2013
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix check against cached pattern for dynamic
always return true for matches against the empty pattern
parent
bedfc9f4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
b06.vtc
src/tests/b06.vtc
+10
-0
vmod_re.c
src/vmod_re.c
+18
-9
No files found.
src/tests/b06.vtc
View file @
33f47f4c
...
...
@@ -5,6 +5,9 @@ server s1 {
txresp -hdr "Foo: baz" -hdr "Bar: baz" -body "foobar"
rxreq
expect req.url == "/foo"
txresp -hdr "Foo: baz" -hdr "Bar: baz" -body "foobar"
rxreq
expect req.url == "/bar"
txresp -hdr "Foo: baz" -hdr "Bar: quux" -body "foobar"
} -start
...
...
@@ -39,6 +42,13 @@ client c1 {
txreq -url "/foo"
rxresp
expect resp.http.foo == "baz"
expect resp.http.bar == "baz"
expect resp.http.static == "match"
expect resp.http.dynamic == "match"
txreq -url "/bar"
rxresp
expect resp.http.foo == "baz"
expect resp.http.bar == "quux"
expect resp.http.static == "match"
expect resp.http.dynamic == "nomatch"
...
...
src/vmod_re.c
View file @
33f47f4c
...
...
@@ -117,22 +117,32 @@ match(struct sess *sp, struct vmod_priv *priv_vcl, struct vmod_priv *priv_call,
{
vre_t
*
re
;
struct
sess_tbl
*
tbl
;
struct
sess_ov
*
ov
;
int
s
;
AN
(
pattern
);
if
(
pattern
==
'\0'
)
return
1
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CAST_OBJ_NOTNULL
(
tbl
,
priv_vcl
->
priv
,
SESS_TBL_MAGIC
);
assert
(
sp
->
id
<
tbl
->
nsess
);
CHECK_OBJ_NOTNULL
(
&
tbl
->
sess
[
sp
->
id
],
SESS_OV_MAGIC
);
AN
(
pattern
)
;
ov
=
&
tbl
->
sess
[
sp
->
id
]
;
if
(
priv_call
->
priv
==
NULL
||
(
dynamic
&&
pattern
!=
tbl
->
sess
[
sp
->
id
].
pattern
))
{
||
(
dynamic
&&
strcmp
(
pattern
,
ov
->
pattern
)
!=
0
))
{
int
erroffset
=
0
;
const
char
*
error
=
NULL
;
AZ
(
pthread_mutex_lock
(
&
re_mutex
));
/*
* Double-check the lock. For dynamic, the pointer would
* have changed by now if another thread was already here,
* so strcmp doesn't have to be repeated.
*/
if
(
priv_call
->
priv
==
NULL
||
(
dynamic
&&
strcmp
(
pattern
,
tbl
->
sess
[
sp
->
id
].
pattern
)))
{
||
(
dynamic
&&
(
pattern
!=
ov
->
pattern
)))
{
priv_call
->
priv
=
VRE_compile
(
pattern
,
0
,
&
error
,
&
erroffset
);
if
(
priv_call
->
priv
==
NULL
)
...
...
@@ -144,8 +154,7 @@ match(struct sess *sp, struct vmod_priv *priv_vcl, struct vmod_priv *priv_call,
priv_call
->
free
=
VRT_re_fini
;
}
if
(
dynamic
)
tbl
->
sess
[
sp
->
id
].
pattern
=
WS_Dup
(
sp
->
wrk
->
ws
,
pattern
);
ov
->
pattern
=
WS_Dup
(
sp
->
wrk
->
ws
,
pattern
);
AZ
(
pthread_mutex_unlock
(
&
re_mutex
));
}
re
=
(
vre_t
*
)
priv_call
->
priv
;
...
...
@@ -154,9 +163,9 @@ match(struct sess *sp, struct vmod_priv *priv_vcl, struct vmod_priv *priv_call,
if
(
str
==
NULL
)
str
=
""
;
s
=
VRE_exec
(
re
,
str
,
strlen
(
str
),
0
,
0
,
&
tbl
->
sess
[
sp
->
id
].
ovector
[
0
],
s
=
VRE_exec
(
re
,
str
,
strlen
(
str
),
0
,
0
,
&
ov
->
ovector
[
0
],
MAX_OV
,
&
params
->
vre_limits
);
tbl
->
sess
[
sp
->
id
].
count
=
s
;
ov
->
count
=
s
;
if
(
s
<
VRE_ERROR_NOMATCH
)
{
WSP
(
sp
,
SLT_VCL_error
,
"vmod re: regex match returned %d"
,
s
);
return
0
;
...
...
@@ -164,7 +173,7 @@ match(struct sess *sp, struct vmod_priv *priv_vcl, struct vmod_priv *priv_call,
if
(
s
==
VRE_ERROR_NOMATCH
)
return
0
;
tbl
->
sess
[
sp
->
id
].
subject
=
WS_Dup
(
sp
->
wrk
->
ws
,
str
);
ov
->
subject
=
WS_Dup
(
sp
->
wrk
->
ws
,
str
);
return
1
;
}
...
...
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