Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-hoailona
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-hoailona
Commits
fef8b26e
Unverified
Commit
fef8b26e
authored
Oct 27, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust to new VRE interface
parent
184eefe0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
25 deletions
+24
-25
pattern.c
src/pattern.c
+23
-23
vmod_hoailona.c
src/vmod_hoailona.c
+1
-2
No files found.
src/pattern.c
View file @
fef8b26e
...
...
@@ -113,20 +113,19 @@ VRBT_GENERATE(assign_tree, assignment, entry, path_cmp)
void
validation_init
(
void
)
{
const
char
*
err
;
int
off
;
int
err
,
off
;
chars
=
VRE_compile
(
"([^A-Za-z0-9 _
\\
-~.%:/
\\
[
\\
]@!$&()*+,;=]+)"
,
0
,
&
err
,
&
off
);
"([^A-Za-z0-9 _
\\
-~.%:/
\\
[
\\
]@!$&()*+,;=]+)"
,
0
,
&
err
,
&
off
,
0
);
AN
(
chars
);
dots
=
VRE_compile
(
"([^/]
\\
.
\\
.
\\
.[^/]*|[^/]*
\\
.
\\
.
\\
.[^/])"
,
0
,
&
err
,
&
off
);
"([^/]
\\
.
\\
.
\\
.[^/]*|[^/]*
\\
.
\\
.
\\
.[^/])"
,
0
,
&
err
,
&
off
,
0
);
AN
(
dots
);
stars
=
VRE_compile
(
"(.?
\\
*{2,}.?)"
,
0
,
&
err
,
&
off
);
"(.?
\\
*{2,}.?)"
,
0
,
&
err
,
&
off
,
0
);
AN
(
stars
);
meta
=
VRE_compile
(
"([[
\\
]$()+])"
,
0
,
&
err
,
&
off
);
"([[
\\
]$()+])"
,
0
,
&
err
,
&
off
,
0
);
AN
(
meta
);
}
...
...
@@ -147,41 +146,42 @@ const char *
valid
(
VRT_CTX
,
const
char
*
restrict
const
path
)
{
const
char
*
errmsg
=
NULL
;
int
r
,
ovector
[
6
];
int
r
;
txt
groups
[
2
];
size_t
len
;
AN
(
path
);
len
=
strlen
(
path
);
memset
(
ovector
,
0
,
sizeof
(
ovector
)
);
r
=
VRE_
exec
(
chars
,
path
,
len
,
0
,
0
,
ovector
,
6
,
NULL
);
memset
(
groups
,
0
,
sizeof
groups
);
r
=
VRE_
capture
(
chars
,
path
,
len
,
0
,
groups
,
2
,
NULL
);
if
(
r
>=
0
)
{
if
((
errmsg
=
WS_Printf
(
ctx
->
ws
,
"invalid character(s) in pattern: %.*s"
,
ovector
[
3
]
-
ovector
[
2
]
,
path
+
ovector
[
2
]
))
(
int
)(
groups
[
1
].
e
-
groups
[
1
].
b
)
,
groups
[
1
].
b
))
==
NULL
)
return
"invalid character(s) in pattern"
;
return
errmsg
;
}
memset
(
ovector
,
0
,
sizeof
(
ovector
)
);
r
=
VRE_
exec
(
dots
,
path
,
len
,
0
,
0
,
ovector
,
6
,
NULL
);
memset
(
groups
,
0
,
sizeof
groups
);
r
=
VRE_
capture
(
dots
,
path
,
len
,
0
,
groups
,
2
,
NULL
);
if
(
r
>=
0
)
{
if
((
errmsg
=
WS_Printf
(
ctx
->
ws
,
"... must only be used before and "
"after slashes: %.*s"
,
ovector
[
3
]
-
ovector
[
2
]
,
path
+
ovector
[
2
]
))
(
int
)(
groups
[
1
].
e
-
groups
[
1
].
b
)
,
groups
[
1
].
b
))
==
NULL
)
return
"... must only be used before and after slashes"
;
return
errmsg
;
}
memset
(
ovector
,
0
,
sizeof
(
ovector
)
);
r
=
VRE_
exec
(
stars
,
path
,
len
,
0
,
0
,
ovector
,
6
,
NULL
);
memset
(
groups
,
0
,
sizeof
groups
);
r
=
VRE_
capture
(
stars
,
path
,
len
,
0
,
groups
,
2
,
NULL
);
if
(
r
>=
0
)
{
if
((
errmsg
=
WS_Printf
(
ctx
->
ws
,
"more than one *: %.*s"
,
ovector
[
3
]
-
ovector
[
2
]
,
path
+
ovector
[
2
]
))
(
int
)(
groups
[
1
].
e
-
groups
[
1
].
b
)
,
groups
[
1
].
b
))
==
NULL
)
return
"more than one *"
;
return
errmsg
;
...
...
@@ -193,9 +193,9 @@ vre_t *
pattern2re
(
VRT_CTX
,
const
char
*
restrict
const
path
)
{
struct
vsb
*
regex
;
const
char
*
esc
,
*
p
,
*
end
,
*
regex_errstr
;
const
char
*
esc
,
*
p
,
*
end
;
uintptr_t
snap
;
int
end_anchor
=
1
,
regex_erroffset
;
int
end_anchor
=
1
,
err
,
off
;
vre_t
*
re
;
AN
(
path
);
...
...
@@ -250,8 +250,8 @@ pattern2re(VRT_CTX, const char * restrict const path)
VSB_putc
(
regex
,
'$'
);
VSB_finish
(
regex
);
re
=
VRE_compile
(
VSB_data
(
regex
),
0
,
&
regex_errstr
,
&
regex_erroffset
);
assert
(
re
!=
NULL
&&
regex_errstr
==
NULL
);
re
=
VRE_compile
(
VSB_data
(
regex
),
0
,
&
err
,
&
off
,
0
);
assert
(
re
!=
NULL
);
VSB_destroy
(
&
regex
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
re
;
...
...
src/vmod_hoailona.c
View file @
fef8b26e
...
...
@@ -597,8 +597,7 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts,
VMOD_HOAILONA_PATTERN_MAGIC
);
AN
(
a
->
pattern
->
re
);
match
=
VRE_exec
(
a
->
pattern
->
re
,
pathname
,
pathlen
,
0
,
0
,
NULL
,
0
,
NULL
);
match
=
VRE_match
(
a
->
pattern
->
re
,
pathname
,
pathlen
,
0
,
NULL
);
if
(
match
>=
0
)
{
assignment
=
a
;
break
;
...
...
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