Adjust to new VRE interface

parent 184eefe0
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment