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
c534480b
Unverified
Commit
c534480b
authored
Feb 10, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using VRT_re_*
parent
93a117ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
10 deletions
+40
-10
pattern.c
src/pattern.c
+24
-5
vmod_hoailona.c
src/vmod_hoailona.c
+15
-5
vmod_hoailona.h
src/vmod_hoailona.h
+1
-0
No files found.
src/pattern.c
View file @
c534480b
...
...
@@ -113,17 +113,36 @@ VRBT_GENERATE(assign_tree, assignment, entry, path_cmp)
void
validation_init
(
void
)
{
VRT_re_init
((
void
**
)
&
chars
,
"([^A-Za-z0-9 _
\\
-~.%:/
\\
[
\\
]@!$&()*+,;=]+)"
);
const
char
*
err
;
int
off
;
chars
=
VRE_compile
(
"([^A-Za-z0-9 _
\\
-~.%:/
\\
[
\\
]@!$&()*+,;=]+)"
,
0
,
&
err
,
&
off
);
AN
(
chars
);
VRT_re_init
((
void
**
)
&
dots
,
"([^/]
\\
.
\\
.
\\
.[^/]*|[^/]*
\\
.
\\
.
\\
.[^/])"
);
dots
=
VRE_compile
(
"([^/]
\\
.
\\
.
\\
.[^/]*|[^/]*
\\
.
\\
.
\\
.[^/])"
,
0
,
&
err
,
&
off
);
AN
(
dots
);
VRT_re_init
((
void
**
)
&
stars
,
"(.?
\\
*{2,}.?)"
);
stars
=
VRE_compile
(
"(.?
\\
*{2,}.?)"
,
0
,
&
err
,
&
off
);
AN
(
stars
);
VRT_re_init
((
void
**
)
&
meta
,
"([[
\\
]$()+])"
);
meta
=
VRE_compile
(
"([[
\\
]$()+])"
,
0
,
&
err
,
&
off
);
AN
(
meta
);
}
void
validation_fini
(
void
)
{
VRE_free
(
&
chars
);
AZ
(
chars
);
VRE_free
(
&
dots
);
AZ
(
dots
);
VRE_free
(
&
stars
);
AZ
(
stars
);
VRE_free
(
&
meta
);
AZ
(
meta
);
}
const
char
*
valid
(
VRT_CTX
,
const
char
*
restrict
const
path
)
{
...
...
src/vmod_hoailona.c
View file @
c534480b
...
...
@@ -110,15 +110,25 @@ get_policy(VRT_CTX, const struct vmod_priv * restrict const,
/* Event function */
static
int
loadcnt
=
0
;
int
v_matchproto_
(
vmod_event_f
)
vmod_event
(
VRT_CTX
,
struct
vmod_priv
*
priv
,
enum
vcl_event_e
e
)
{
(
void
)
ctx
;
(
void
)
priv
;
if
(
e
==
VCL_EVENT_LOAD
)
validation_init
();
return
0
;
switch
(
e
)
{
case
VCL_EVENT_LOAD
:
if
(
loadcnt
++
==
0
)
validation_init
();
return
(
0
);
case
VCL_EVENT_DISCARD
:
if
(
--
loadcnt
==
0
)
validation_fini
();
return
(
0
);
default:
return
(
0
);
}
}
/* Object policy */
...
...
@@ -295,7 +305,7 @@ vmod_hosts__fini(struct vmod_hoailona_hosts **hostsp)
if
(
a
->
pattern
->
path
!=
NULL
)
free
(
a
->
pattern
->
path
);
if
(
a
->
pattern
->
re
!=
NULL
)
VR
T_re_fini
(
a
->
pattern
->
re
);
VR
E_free
(
&
a
->
pattern
->
re
);
}
next_ass
=
VRBT_NEXT
(
assign_tree
,
a
,
a
);
FREE_OBJ
(
a
);
...
...
@@ -436,7 +446,7 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
result
->
policy
->
vcl_name
,
hostname
,
path
,
hosts
->
vcl_name
);
if
(
re
!=
NULL
)
VR
T_re_fini
(
re
);
VR
E_free
(
&
re
);
return
;
}
}
...
...
src/vmod_hoailona.h
View file @
c534480b
...
...
@@ -75,6 +75,7 @@ int path_cmp(const struct assignment * restrict const ass_a,
VRBT_PROTOTYPE
(
assign_tree
,
assignment
,
entry
,
path_cmp
)
void
validation_init
(
void
);
void
validation_fini
(
void
);
const
char
*
valid
(
VRT_CTX
,
const
char
*
restrict
const
path
);
vre_t
*
pattern2re
(
VRT_CTX
,
const
char
*
restrict
const
path
);
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