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
uplex-varnish
libvmod-re
Commits
3c0e0572
Unverified
Commit
3c0e0572
authored
Aug 02, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compatibility with VRE api changes
see
https://github.com/varnishcache/varnish-cache/pull/3655
parent
96250e04
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
27 deletions
+36
-27
README.rst
README.rst
+2
-2
vmod_re.c
src/vmod_re.c
+34
-25
No files found.
README.rst
View file @
3c0e0572
..
.. NB: This file is machine generated, DO NOT EDIT!
..
.. Edit
vmod
.vcc and run make instead
.. Edit
../src/vmod_re
.vcc and run make instead
..
.. role:: ref(emphasis)
=======
VMOD
re
vmod_
re
=======
-------------------------------------------------------------------------
...
...
src/vmod_re.c
View file @
3c0e0572
...
...
@@ -35,24 +35,12 @@
#include "cache/cache.h"
#include "vcl.h"
#include "vre.h"
#include "vsb.h"
#include "vcc_if.h"
/* pcreapi(3):
*
* The first two-thirds of the vector is used to pass back captured
* substrings, each substring using a pair of integers. The remaining
* third of the vector is used as workspace by pcre_exec() while matching
* capturing subpatterns, and is not available for passing back
* information.
*
* XXX: if vre were to expose the pcre and pcre_extra objects, then we
* could use pcre_fullinfo() to determine the highest backref for each
* regex, and wouldn't need this arbitrary limit ...
*/
#define MAX_MATCHES 11
#define MAX_OV ((MAX_MATCHES) * 3)
#define MAX_OV_USED ((MAX_MATCHES) * 2)
#define MAX_OV ((MAX_MATCHES) * 2)
struct
vmod_re_regex
{
unsigned
magic
;
...
...
@@ -65,7 +53,7 @@ typedef struct ov_s {
unsigned
magic
;
#define OV_MAGIC 0x844bfa39
const
char
*
subject
;
int
ovector
[
MAX_OV
_USED
];
int
ovector
[
MAX_OV
];
}
ov_t
;
static
void
...
...
@@ -82,12 +70,32 @@ errmsg(VRT_CTX, const char *fmt, ...)
va_end
(
args
);
}
static
vre_t
*
re_compile
(
const
char
*
pattern
,
unsigned
options
,
char
*
errbuf
,
size_t
errbufsz
,
int
*
erroffset
)
{
static
vre_t
*
vre
;
struct
vsb
vsb
[
1
];
int
errcode
;
vre
=
VRE_compile
(
pattern
,
options
,
&
errcode
,
erroffset
,
1
);
if
(
vre
!=
NULL
)
return
(
vre
);
AN
(
VSB_init
(
vsb
,
errbuf
,
errbufsz
));
AZ
(
VRE_error
(
vsb
,
errcode
));
AZ
(
VSB_finish
(
vsb
));
VSB_fini
(
vsb
);
return
(
NULL
);
}
VCL_VOID
vmod_regex__init
(
VRT_CTX
,
struct
vmod_re_regex
**
rep
,
const
char
*
vcl_name
,
VCL_STRING
pattern
,
VCL_INT
limit
,
VCL_INT
limit_recursion
)
{
struct
vmod_re_regex
*
re
;
vre_t
*
vre
;
char
errbuf
[
VRE_ERROR_LEN
];
int
erroffset
;
const
char
*
error
;
...
...
@@ -109,10 +117,11 @@ vmod_regex__init(VRT_CTX, struct vmod_re_regex **rep, const char *vcl_name,
return
;
}
if
((
vre
=
VRE_compile
(
pattern
,
0
,
&
error
,
&
erroffset
))
==
NULL
)
{
vre
=
re_compile
(
pattern
,
0
,
errbuf
,
sizeof
errbuf
,
&
erroffset
);
if
(
vre
==
NULL
)
{
VRT_fail
(
ctx
,
"vmod re: error compiling regex
\"
%s
\"
in %s "
"constructor: %s (at offset %d)"
,
pattern
,
vcl_name
,
err
or
,
erroffset
);
err
buf
,
erroffset
);
return
;
}
...
...
@@ -120,7 +129,7 @@ vmod_regex__init(VRT_CTX, struct vmod_re_regex **rep, const char *vcl_name,
AN
(
re
);
re
->
vre
=
vre
;
re
->
vre_limits
.
match
=
limit
;
re
->
vre_limits
.
match_recursion
=
limit_recursion
;
re
->
vre_limits
.
depth
=
limit_recursion
;
*
rep
=
re
;
}
...
...
@@ -223,7 +232,7 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback,
CAST_OBJ_NOTNULL
(
ov
,
task
->
priv
,
OV_MAGIC
);
refnum
*=
2
;
assert
(
refnum
+
1
<
MAX_OV
_USED
);
assert
(
refnum
+
1
<
MAX_OV
);
if
(
ov
->
ovector
[
refnum
]
==
-
1
)
return
fallback
;
...
...
@@ -255,9 +264,9 @@ get_limits(const struct vmod_re_regex *re, struct vre_limits *limits,
limits
->
match
=
re
->
vre_limits
.
match
;
if
(
limit_recursion
>
0
)
limits
->
match_recursion
=
limit_recursion
;
limits
->
depth
=
limit_recursion
;
else
limits
->
match_recursion
=
re
->
vre_limits
.
match_recursion
;
limits
->
depth
=
re
->
vre_limits
.
depth
;
return
(
limits
);
}
...
...
@@ -308,8 +317,8 @@ vmod_match_dyn(VRT_CTX, struct vmod_priv *task, VCL_STRING pattern,
VCL_STRING
subject
,
VCL_INT
limit
,
VCL_INT
limit_recursion
)
{
vre_t
*
vre
;
char
errbuf
[
VRE_ERROR_LEN
];
int
erroffset
;
const
char
*
error
;
VCL_BOOL
dyn_return
;
struct
vre_limits
limits
;
...
...
@@ -329,14 +338,14 @@ vmod_match_dyn(VRT_CTX, struct vmod_priv *task, VCL_STRING pattern,
}
limits
.
match
=
limit
;
limits
.
match_recursion
=
limit_recursion
;
limits
.
depth
=
limit_recursion
;
task
->
len
=
0
;
vre
=
VRE_compile
(
pattern
,
0
,
&
error
,
&
erroffset
);
vre
=
re_compile
(
pattern
,
0
,
errbuf
,
sizeof
errbuf
,
&
erroffset
);
if
(
vre
==
NULL
)
{
VSLb
(
ctx
->
vsl
,
SLT_VCL_Error
,
"vmod re: error compiling regex
\"
%s
\"
: %s (position %d)"
,
pattern
,
err
or
,
erroffset
);
pattern
,
err
buf
,
erroffset
);
return
0
;
}
...
...
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