Commit 645789a2 authored by Geoff Simmons's avatar Geoff Simmons

Add the info_bool() method.

parent 62df17f1
Pipeline #265 skipped
......@@ -94,6 +94,15 @@ regex.sub
STRING regex.sub(PRIV_CALL, PRIV_TASK, STRING subject, STRING replacement, INT len=0, BOOL anchored=0, INT match_limit=0, INT offset_limit=0, BOOL notbol=0, BOOL noteol=0, BOOL notempty=0, BOOL notempty_atstart=0, BOOL no_jit=0, BOOL no_utf_check=0, INT recursion_limit=0, BOOL suball=0, BOOL sub_extended=0, BOOL unknown_unset=0, BOOL unset_empty=0)
.. _func_regex.info_bool:
regex.info_bool
---------------
::
BOOL regex.info_bool(ENUM {ALLOW_EMPTY_CLASS,ANCHORED,ALT_BSUX,ALT_CIRCUMFLEX,ALT_VERBNAMES,CASELESS,DOLLAR_ENDONLY,DOTALL,DUPNAMES,EXTENDED,FIRSTLINE,MATCH_UNSET_BACKREF,MULTILINE,NEVER_BACKSLASH_C,NEVER_UCP,NEVER_UTF,NO_AUTO_CAPTURE,NO_AUTO_POSSESS,NO_DOTSTAR_ANCHOR,NO_START_OPTIMIZE,NO_UTF_CHECK,UCP,UNGREEDY,USE_OFFSET_LIMIT,UTF,HAS_FIRSTCODEUNIT,MATCH_ATSTART,HAS_LASTCODEUNIT,HAS_BACKSLASHC,HAS_CRORLF,JCHANGED,MATCH_EMPTY}, BOOL compiled=1)
.. _func_regex.info_int:
regex.info_int
......
......@@ -29,6 +29,150 @@
#include "vcc_if.h"
VCL_BOOL
vmod_regex_info_bool(VRT_CTX, struct vmod_pcre2_regex *regex, VCL_ENUM bools,
VCL_BOOL compiled)
{
uint32_t what, where, option, opts = PCRE2_INFO_ALLOPTIONS, codetype;
int ret;
(void) ctx;
CHECK_OBJ_NOTNULL(regex, VMOD_PCRE2_REGEX_MAGIC);
if (!compiled)
opts = PCRE2_INFO_ARGOPTIONS;
if (strcmp(bools, "ALLOW_EMPTY_CLASS") == 0) {
what = opts;
option = PCRE2_ALLOW_EMPTY_CLASS;
}
else if (strcmp(bools, "ANCHORED") == 0) {
what = opts;
option = PCRE2_ANCHORED;
}
else if (strcmp(bools, "ALT_BSUX") == 0) {
what = opts;
option = PCRE2_ANCHORED;
}
else if (strcmp(bools, "ALT_CIRCUMFLEX") == 0) {
what = opts;
option = PCRE2_ALT_CIRCUMFLEX;
}
else if (strcmp(bools, "ALT_VERBNAMES") == 0) {
what = opts;
option = PCRE2_ALT_VERBNAMES;
}
else if (strcmp(bools, "CASELESS") == 0) {
what = opts;
option = PCRE2_CASELESS;
}
else if (strcmp(bools, "DOLLAR_ENDONLY") == 0) {
what = opts;
option = PCRE2_DOLLAR_ENDONLY;
}
else if (strcmp(bools, "DOTALL") == 0) {
what = opts;
option = PCRE2_DOTALL;
}
else if (strcmp(bools, "DUPNAMES") == 0) {
what = opts;
option = PCRE2_DUPNAMES;
}
else if (strcmp(bools, "EXTENDED") == 0) {
what = opts;
option = PCRE2_EXTENDED;
}
else if (strcmp(bools, "FIRSTLINE") == 0) {
what = opts;
option = PCRE2_FIRSTLINE;
}
else if (strcmp(bools, "MATCH_UNSET_BACKREF") == 0) {
what = opts;
option = PCRE2_MATCH_UNSET_BACKREF;
}
else if (strcmp(bools, "MULTILINE") == 0) {
what = opts;
option = PCRE2_MULTILINE;
}
else if (strcmp(bools, "NEVER_BACKSLASH_C") == 0) {
what = opts;
option = PCRE2_NEVER_BACKSLASH_C;
}
else if (strcmp(bools, "NEVER_UCP") == 0) {
what = opts;
option = PCRE2_NEVER_UCP;
}
else if (strcmp(bools, "NEVER_UTF") == 0) {
what = opts;
option = PCRE2_NEVER_UTF;
}
else if (strcmp(bools, "NO_AUTO_CAPTURE") == 0) {
what = opts;
option = PCRE2_NO_AUTO_CAPTURE;
}
else if (strcmp(bools, "NO_AUTO_POSSESS") == 0) {
what = opts;
option = PCRE2_NO_AUTO_POSSESS;
}
else if (strcmp(bools, "NO_DOTSTAR_ANCHOR") == 0) {
what = opts;
option = PCRE2_NO_DOTSTAR_ANCHOR;
}
else if (strcmp(bools, "NO_START_OPTIMIZE") == 0) {
what = opts;
option = PCRE2_NO_START_OPTIMIZE;
}
else if (strcmp(bools, "NO_UTF_CHECK") == 0) {
what = opts;
option = PCRE2_NO_UTF_CHECK;
}
else if (strcmp(bools, "UCP") == 0) {
what = opts;
option = PCRE2_UCP;
}
else if (strcmp(bools, "UNGREEDY") == 0) {
what = opts;
option = PCRE2_UNGREEDY;
}
else if (strcmp(bools, "USE_OFFSET_LIMIT") == 0) {
what = opts;
option = PCRE2_USE_OFFSET_LIMIT;
}
else if (strcmp(bools, "UTF") == 0) {
what = opts;
option = PCRE2_UTF;
}
else if (strcmp(bools, "HAS_FIRSTCODEUNIT") == 0) {
what = PCRE2_INFO_FIRSTCODETYPE;
codetype = 1;
}
else if (strcmp(bools, "MATCH_ATSTART") == 0) {
what = PCRE2_INFO_FIRSTCODETYPE;
codetype = 2;
}
else if (strcmp(bools, "HAS_LASTCODEUNIT") == 0)
what = PCRE2_INFO_LASTCODETYPE;
else if (strcmp(bools, "HAS_BACKSLASHC") == 0)
what = PCRE2_INFO_HASBACKSLASHC;
else if (strcmp(bools, "HAS_CRORLF") == 0)
what = PCRE2_INFO_HASCRORLF;
else if (strcmp(bools, "JCHANGED") == 0)
what = PCRE2_INFO_JCHANGED;
else if (strcmp(bools, "MATCH_EMPTY") == 0)
what = PCRE2_INFO_MATCHEMPTY;
else
WRONG("illegal enum in info_int");
ret = pcre2_pattern_info(regex->code, what, &where);
AZ(ret);
if (what == opts)
return (where & option);
if (what == PCRE2_INFO_FIRSTCODETYPE)
return where == codetype;
return where;
}
VCL_INT
vmod_regex_info_int(VRT_CTX, struct vmod_pcre2_regex *regex, VCL_ENUM ints)
{
......
......@@ -38,6 +38,7 @@ varnish v1 -vcl {
= pcre2.match("\o{170000}", "飥", utf=true);
set resp.http.f6
= pcre2.match("[膧-膭]", "膫", utf=true);
set resp.http.info = r1.info_bool(UTF);
}
} -start
......@@ -51,6 +52,7 @@ client c1 {
expect resp.http.f4 == "true"
expect resp.http.f5 == "true"
expect resp.http.f6 == "true"
expect resp.http.info == "true"
} -run
varnish v1 -errvcl {vmod pcre2 error: Cannot compile '\x{110000}' in r constructor: character code point value in \x{} or \o{} is too large at offset 9} {
......
......@@ -7,7 +7,7 @@ varnish v1 -vcl {
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex(
new r = pcre2.regex(
"(*LIMIT_MATCH=20)(*LIMIT_RECURSION=30)(?<!bar|cattle)a(bc)\1");
}
......@@ -16,14 +16,16 @@ varnish v1 -vcl {
}
sub vcl_synth {
set resp.http.backrefmax = r1.info_int(BACKREFMAX);
set resp.http.capturecount = r1.info_int(CAPTURECOUNT);
set resp.http.jitsize = r1.info_int(JITSIZE);
set resp.http.matchlimit = r1.info_int(MATCHLIMIT);
set resp.http.maxlookbehind = r1.info_int(MAXLOOKBEHIND);
set resp.http.minlength = r1.info_int(MINLENGTH);
set resp.http.recursionlimit = r1.info_int(RECURSIONLIMIT);
set resp.http.size = r1.info_int(SIZE);
set resp.http.backrefmax = r.info_int(BACKREFMAX);
set resp.http.capturecount = r.info_int(CAPTURECOUNT);
set resp.http.jitsize = r.info_int(JITSIZE);
set resp.http.matchlimit = r.info_int(MATCHLIMIT);
set resp.http.maxlookbehind = r.info_int(MAXLOOKBEHIND);
set resp.http.minlength = r.info_int(MINLENGTH);
set resp.http.recursionlimit = r.info_int(RECURSIONLIMIT);
set resp.http.size = r.info_int(SIZE);
return(deliver);
}
} -start
......@@ -40,3 +42,560 @@ client c1 {
expect resp.http.recursionlimit == 30
expect resp.http.size > 0
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("abc");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.allow_empty = r.info_bool(ALLOW_EMPTY_CLASS);
set resp.http.allow_empty_arg
= r.info_bool(ALLOW_EMPTY_CLASS, compiled=false);
set resp.http.anchored = r.info_bool(ANCHORED);
set resp.http.anchored_arg
= r.info_bool(ANCHORED, compiled=false);
set resp.http.alt_bsux = r.info_bool(ALT_BSUX);
set resp.http.alt_bsux_arg
= r.info_bool(ALT_BSUX, compiled=false);
set resp.http.alt_circumflex = r.info_bool(ALT_CIRCUMFLEX);
set resp.http.alt_circumflex_arg
= r.info_bool(ALT_CIRCUMFLEX, compiled=false);
set resp.http.alt_verbnames = r.info_bool(ALT_VERBNAMES);
set resp.http.alt_verbnames_arg
= r.info_bool(ALT_VERBNAMES, compiled=false);
set resp.http.caseless = r.info_bool(CASELESS);
set resp.http.caseless_arg
= r.info_bool(CASELESS, compiled=false);
set resp.http.dollar_endonly = r.info_bool(DOLLAR_ENDONLY);
set resp.http.dollar_endonly_arg
= r.info_bool(DOLLAR_ENDONLY, compiled=false);
set resp.http.dotall = r.info_bool(DOTALL);
set resp.http.dotall_arg = r.info_bool(DOTALL, compiled=false);
set resp.http.dupnames = r.info_bool(DUPNAMES);
set resp.http.dupnames_arg
= r.info_bool(DUPNAMES, compiled=false);
set resp.http.extended = r.info_bool(EXTENDED);
set resp.http.extended_arg
= r.info_bool(EXTENDED, compiled=false);
set resp.http.firstline = r.info_bool(FIRSTLINE);
set resp.http.firstline_arg
= r.info_bool(FIRSTLINE, compiled=false);
set resp.http.match_unset_backref
= r.info_bool(MATCH_UNSET_BACKREF);
set resp.http.match_unset_backref_arg
= r.info_bool(MATCH_UNSET_BACKREF, compiled=false);
set resp.http.multiline = r.info_bool(MULTILINE);
set resp.http.multiline_arg
= r.info_bool(MULTILINE, compiled=false);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.allow_empty == "false"
expect resp.http.allow_empty_arg == "false"
expect resp.http.anchored == "false"
expect resp.http.anchored_arg == "false"
expect resp.http.alt_bsux == "false"
expect resp.http.alt_bsux_arg == "false"
expect resp.http.alt_circumflex == "false"
expect resp.http.alt_circumflex_arg == "false"
expect resp.http.alt_verbnames == "false"
expect resp.http.alt_verbnames_arg == "false"
expect resp.http.caseless == "false"
expect resp.http.caseless_arg == "false"
expect resp.http.dollar_endonly == "false"
expect resp.http.dollar_endonly_arg == "false"
expect resp.http.dotall == "false"
expect resp.http.dotall_arg == "false"
expect resp.http.dupnames == "false"
expect resp.http.dupnames_arg == "false"
expect resp.http.extended == "false"
expect resp.http.extended_arg == "false"
expect resp.http.firstline == "false"
expect resp.http.firstline_arg == "false"
expect resp.http.match_unset_backref == "false"
expect resp.http.match_unset_backref_arg == "false"
expect resp.http.multiline == "false"
expect resp.http.multiline_arg == "false"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("abc");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.never_backslash_c
= r.info_bool(NEVER_BACKSLASH_C);
set resp.http.never_backslash_c_arg
= r.info_bool(NEVER_BACKSLASH_C, compiled=false);
set resp.http.never_ucp = r.info_bool(NEVER_UCP);
set resp.http.never_ucp_arg
= r.info_bool(NEVER_UCP, compiled=false);
set resp.http.never_utf = r.info_bool(NEVER_UTF);
set resp.http.never_utf_arg
= r.info_bool(NEVER_UTF, compiled=false);
set resp.http.no_auto_capture = r.info_bool(NO_AUTO_CAPTURE);
set resp.http.no_auto_capture_arg
= r.info_bool(NO_AUTO_CAPTURE, compiled=false);
set resp.http.no_auto_possess = r.info_bool(NO_AUTO_POSSESS);
set resp.http.no_auto_possess_arg
= r.info_bool(NO_AUTO_POSSESS, compiled=false);
set resp.http.no_dotstar_anchor
= r.info_bool(NO_DOTSTAR_ANCHOR);
set resp.http.no_dotstar_anchor_arg
= r.info_bool(NO_DOTSTAR_ANCHOR, compiled=false);
set resp.http.no_start_optimize
= r.info_bool(NO_START_OPTIMIZE);
set resp.http.no_start_optimize_arg
= r.info_bool(NO_START_OPTIMIZE, compiled=false);
set resp.http.no_utf_check = r.info_bool(NO_UTF_CHECK);
set resp.http.no_utf_check_arg
= r.info_bool(NO_UTF_CHECK, compiled=false);
set resp.http.ucp = r.info_bool(UCP);
set resp.http.ucp_arg = r.info_bool(UCP, compiled=false);
set resp.http.ungreedy = r.info_bool(UNGREEDY);
set resp.http.ungreedy_arg
= r.info_bool(UNGREEDY, compiled=false);
set resp.http.use_offset_limit = r.info_bool(USE_OFFSET_LIMIT);
set resp.http.use_offset_limit_arg
= r.info_bool(USE_OFFSET_LIMIT, compiled=false);
set resp.http.utf = r.info_bool(UTF);
set resp.http.utf_arg = r.info_bool(UTF, compiled=false);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.never_backslash_c == "false"
expect resp.http.never_backslash_c_arg == "false"
expect resp.http.never_ucp == "false"
expect resp.http.never_ucp_arg == "false"
expect resp.http.never_utf == "false"
expect resp.http.never_utf_arg == "false"
expect resp.http.no_auto_capture == "false"
expect resp.http.no_auto_capture_arg == "false"
expect resp.http.no_auto_possess == "false"
expect resp.http.no_auto_possess_arg == "false"
expect resp.http.no_dotstar_anchor == "false"
expect resp.http.no_dotstar_anchor_arg == "false"
expect resp.http.no_start_optimize == "false"
expect resp.http.no_start_optimize_arg == "false"
expect resp.http.no_utf_check == "false"
expect resp.http.no_utf_check_arg == "false"
expect resp.http.ucp == "false"
expect resp.http.ucp_arg == "false"
expect resp.http.ungreedy == "false"
expect resp.http.ungreedy_arg == "false"
expect resp.http.use_offset_limit == "false"
expect resp.http.use_offset_limit_arg == "false"
expect resp.http.utf == "false"
expect resp.http.utf_arg == "false"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r
= pcre2.regex("abc", allow_empty_class=true, anchored=true,
alt_bsux=true, alt_circumflex=true,
alt_verbnames=true, caseless=true,
dollar_endonly=true, dotall=true,
dupnames=true, extended=true, firstline=true,
match_unset_backref=true, multiline=true);
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.allow_empty = r.info_bool(ALLOW_EMPTY_CLASS);
set resp.http.allow_empty_arg
= r.info_bool(ALLOW_EMPTY_CLASS, compiled=false);
set resp.http.anchored = r.info_bool(ANCHORED);
set resp.http.anchored_arg
= r.info_bool(ANCHORED, compiled=false);
set resp.http.alt_bsux = r.info_bool(ALT_BSUX);
set resp.http.alt_bsux_arg
= r.info_bool(ALT_BSUX, compiled=false);
set resp.http.alt_circumflex = r.info_bool(ALT_CIRCUMFLEX);
set resp.http.alt_circumflex_arg
= r.info_bool(ALT_CIRCUMFLEX, compiled=false);
set resp.http.alt_verbnames = r.info_bool(ALT_VERBNAMES);
set resp.http.alt_verbnames_arg
= r.info_bool(ALT_VERBNAMES, compiled=false);
set resp.http.caseless = r.info_bool(CASELESS);
set resp.http.caseless_arg
= r.info_bool(CASELESS, compiled=false);
set resp.http.dollar_endonly = r.info_bool(DOLLAR_ENDONLY);
set resp.http.dollar_endonly_arg
= r.info_bool(DOLLAR_ENDONLY, compiled=false);
set resp.http.dotall = r.info_bool(DOTALL);
set resp.http.dotall_arg = r.info_bool(DOTALL, compiled=false);
set resp.http.dupnames = r.info_bool(DUPNAMES);
set resp.http.dupnames_arg
= r.info_bool(DUPNAMES, compiled=false);
set resp.http.extended = r.info_bool(EXTENDED);
set resp.http.extended_arg
= r.info_bool(EXTENDED, compiled=false);
set resp.http.firstline = r.info_bool(FIRSTLINE);
set resp.http.firstline_arg
= r.info_bool(FIRSTLINE, compiled=false);
set resp.http.match_unset_backref
= r.info_bool(MATCH_UNSET_BACKREF);
set resp.http.match_unset_backref_arg
= r.info_bool(MATCH_UNSET_BACKREF, compiled=false);
set resp.http.multiline = r.info_bool(MULTILINE);
set resp.http.multiline_arg
= r.info_bool(MULTILINE, compiled=false);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.allow_empty == "true"
expect resp.http.allow_empty_arg == "true"
expect resp.http.anchored == "true"
expect resp.http.anchored_arg == "true"
expect resp.http.alt_bsux == "true"
expect resp.http.alt_bsux_arg == "true"
expect resp.http.alt_circumflex == "true"
expect resp.http.alt_circumflex_arg == "true"
expect resp.http.alt_verbnames == "true"
expect resp.http.alt_verbnames_arg == "true"
expect resp.http.caseless == "true"
expect resp.http.caseless_arg == "true"
expect resp.http.dollar_endonly == "true"
expect resp.http.dollar_endonly_arg == "true"
expect resp.http.dotall == "true"
expect resp.http.dotall_arg == "true"
expect resp.http.dupnames == "true"
expect resp.http.dupnames_arg == "true"
expect resp.http.extended == "true"
expect resp.http.extended_arg == "true"
expect resp.http.firstline == "true"
expect resp.http.firstline_arg == "true"
expect resp.http.match_unset_backref == "true"
expect resp.http.match_unset_backref_arg == "true"
expect resp.http.multiline == "true"
expect resp.http.multiline_arg == "true"
} -run
# Testing UTF for true is done in the UTF8-dependent tests
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1
= pcre2.regex("abc", never_backslash_c=true, never_ucp=true,
never_utf=true, no_auto_capture=true,
no_auto_possess=true, no_dotstar_anchor=true,
no_start_optimize=true, no_utf_check=true,
ungreedy=true, use_offset_limit=true);
new r2 = pcre2.regex("abc", ucp=true);
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.never_backslash_c
= r1.info_bool(NEVER_BACKSLASH_C);
set resp.http.never_backslash_c_arg
= r1.info_bool(NEVER_BACKSLASH_C, compiled=false);
set resp.http.never_ucp = r1.info_bool(NEVER_UCP);
set resp.http.never_ucp_arg
= r1.info_bool(NEVER_UCP, compiled=false);
set resp.http.never_utf = r1.info_bool(NEVER_UTF);
set resp.http.never_utf_arg
= r1.info_bool(NEVER_UTF, compiled=false);
set resp.http.no_auto_capture = r1.info_bool(NO_AUTO_CAPTURE);
set resp.http.no_auto_capture_arg
= r1.info_bool(NO_AUTO_CAPTURE, compiled=false);
set resp.http.no_auto_possess = r1.info_bool(NO_AUTO_POSSESS);
set resp.http.no_auto_possess_arg
= r1.info_bool(NO_AUTO_POSSESS, compiled=false);
set resp.http.no_dotstar_anchor
= r1.info_bool(NO_DOTSTAR_ANCHOR);
set resp.http.no_dotstar_anchor_arg
= r1.info_bool(NO_DOTSTAR_ANCHOR, compiled=false);
set resp.http.no_start_optimize
= r1.info_bool(NO_START_OPTIMIZE);
set resp.http.no_start_optimize_arg
= r1.info_bool(NO_START_OPTIMIZE, compiled=false);
set resp.http.no_utf_check = r1.info_bool(NO_UTF_CHECK);
set resp.http.no_utf_check_arg
= r1.info_bool(NO_UTF_CHECK, compiled=false);
set resp.http.ucp = r2.info_bool(UCP);
set resp.http.ucp_arg = r2.info_bool(UCP, compiled=false);
set resp.http.ungreedy = r1.info_bool(UNGREEDY);
set resp.http.ungreedy_arg
= r1.info_bool(UNGREEDY, compiled=false);
set resp.http.use_offset_limit = r1.info_bool(USE_OFFSET_LIMIT);
set resp.http.use_offset_limit_arg
= r1.info_bool(USE_OFFSET_LIMIT, compiled=false);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.never_backslash_c == "true"
expect resp.http.never_backslash_c_arg == "true"
expect resp.http.never_ucp == "true"
expect resp.http.never_ucp_arg == "true"
expect resp.http.never_utf == "true"
expect resp.http.never_utf_arg == "true"
expect resp.http.no_auto_capture == "true"
expect resp.http.no_auto_capture_arg == "true"
expect resp.http.no_auto_possess == "true"
expect resp.http.no_auto_possess_arg == "true"
expect resp.http.no_dotstar_anchor == "true"
expect resp.http.no_dotstar_anchor_arg == "true"
expect resp.http.no_start_optimize == "true"
expect resp.http.no_start_optimize_arg == "true"
expect resp.http.no_utf_check == "true"
expect resp.http.no_utf_check_arg == "true"
expect resp.http.ucp == "true"
expect resp.http.ucp_arg == "true"
expect resp.http.ungreedy == "true"
expect resp.http.ungreedy_arg == "true"
expect resp.http.use_offset_limit == "true"
expect resp.http.use_offset_limit_arg == "true"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("^abc");
new r2 = pcre2.regex("^abc", multiline=true);
new r3 = pcre2.regex("(*UCP)abc");
new r4 = pcre2.regex("(*NO_AUTO_POSSESS)abc");
new r5 = pcre2.regex("(*NO_START_OPT)abc");
new r6 = pcre2.regex("(*NO_DOTSTAR_ANCHOR).*abc");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.anchored-1 = r1.info_bool(ANCHORED);
set resp.http.anchored_arg-1
= r1.info_bool(ANCHORED, compiled=false);
set resp.http.anchored-2 = r2.info_bool(ANCHORED);
set resp.http.anchored_arg-2
= r2.info_bool(ANCHORED, compiled=false);
set resp.http.ucp = r3.info_bool(UCP);
set resp.http.ucp_arg = r3.info_bool(UCP, compiled=false);
set resp.http.no_auto_possess = r4.info_bool(NO_AUTO_POSSESS);
set resp.http.no_auto_possess_arg
= r4.info_bool(NO_AUTO_POSSESS, compiled=false);
set resp.http.no_start_optimize
= r5.info_bool(NO_START_OPTIMIZE);
set resp.http.no_start_optimize_arg
= r5.info_bool(NO_START_OPTIMIZE, compiled=false);
set resp.http.no_dotstar_anchor
= r6.info_bool(NO_DOTSTAR_ANCHOR);
set resp.http.no_dotstar_anchor_arg
= r6.info_bool(NO_DOTSTAR_ANCHOR, compiled=false);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.anchored-1 == "true"
expect resp.http.anchored_arg-1 == "false"
expect resp.http.anchored-2 == "false"
expect resp.http.anchored_arg-2 == "false"
expect resp.http.ucp == "true"
expect resp.http.ucp_arg == "false"
expect resp.http.no_auto_possess == "true"
expect resp.http.no_auto_possess_arg == "false"
expect resp.http.no_start_optimize == "true"
expect resp.http.no_start_optimize_arg == "false"
expect resp.http.no_dotstar_anchor == "true"
expect resp.http.no_dotstar_anchor_arg == "false"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a+bc");
new r2 = pcre2.regex("^a+bc");
new r3 = pcre2.regex(".*b");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.first-1 = r1.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-1 = r1.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-1 = r1.info_bool(MATCH_ATSTART);
set resp.http.bsc-1 = r1.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-1 = r1.info_bool(HAS_CRORLF);
set resp.http.jchanged-1 = r1.info_bool(JCHANGED);
set resp.http.empty-1 = r1.info_bool(MATCH_EMPTY);
set resp.http.first-2 = r2.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-2 = r2.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-2 = r2.info_bool(MATCH_ATSTART);
set resp.http.bsc-2 = r2.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-2 = r2.info_bool(HAS_CRORLF);
set resp.http.jchanged-2 = r2.info_bool(JCHANGED);
set resp.http.empty-2 = r2.info_bool(MATCH_EMPTY);
set resp.http.first-3 = r3.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-3 = r3.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-3 = r3.info_bool(MATCH_ATSTART);
set resp.http.bsc-3 = r3.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-3 = r3.info_bool(HAS_CRORLF);
set resp.http.jchanged-3 = r3.info_bool(JCHANGED);
set resp.http.empty-3 = r3.info_bool(MATCH_EMPTY);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.first-1 == "true"
expect resp.http.last-1 == "true"
expect resp.http.start-1 == "false"
expect resp.http.bsc-1 == "false"
expect resp.http.crlf-1 == "false"
expect resp.http.jchanged-1 == "false"
expect resp.http.empty-1 == "false"
expect resp.http.first-2 == "false"
expect resp.http.last-2 == "true"
expect resp.http.start-2 == "false"
expect resp.http.bsc-2 == "false"
expect resp.http.crlf-2 == "false"
expect resp.http.jchanged-2 == "false"
expect resp.http.empty-2 == "false"
expect resp.http.first-3 == "false"
expect resp.http.last-3 == "true"
expect resp.http.start-3 == "true"
expect resp.http.bsc-3 == "false"
expect resp.http.crlf-3 == "false"
expect resp.http.jchanged-3 == "false"
expect resp.http.empty-3 == "false"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a\Cb\nc");
new r2 = pcre2.regex("(?-J)\r");
new r3 = pcre2.regex(".*|abc");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.first-1 = r1.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-1 = r1.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-1 = r1.info_bool(MATCH_ATSTART);
set resp.http.bsc-1 = r1.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-1 = r1.info_bool(HAS_CRORLF);
set resp.http.jchanged-1 = r1.info_bool(JCHANGED);
set resp.http.empty-1 = r1.info_bool(MATCH_EMPTY);
set resp.http.first-2 = r2.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-2 = r2.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-2 = r2.info_bool(MATCH_ATSTART);
set resp.http.bsc-2 = r2.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-2 = r2.info_bool(HAS_CRORLF);
set resp.http.jchanged-2 = r2.info_bool(JCHANGED);
set resp.http.empty-2 = r2.info_bool(MATCH_EMPTY);
set resp.http.first-3 = r3.info_bool(HAS_FIRSTCODEUNIT);
set resp.http.last-3 = r3.info_bool(HAS_LASTCODEUNIT);
set resp.http.start-3 = r3.info_bool(MATCH_ATSTART);
set resp.http.bsc-3 = r3.info_bool(HAS_BACKSLASHC);
set resp.http.crlf-3 = r3.info_bool(HAS_CRORLF);
set resp.http.jchanged-3 = r3.info_bool(JCHANGED);
set resp.http.empty-3 = r3.info_bool(MATCH_EMPTY);
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.first-1 == "true"
expect resp.http.last-1 == "true"
expect resp.http.start-1 == "false"
expect resp.http.bsc-1 == "true"
expect resp.http.crlf-1 == "true"
expect resp.http.jchanged-1 == "false"
expect resp.http.empty-1 == "false"
expect resp.http.first-2 == "true"
expect resp.http.last-2 == "false"
expect resp.http.start-2 == "false"
expect resp.http.bsc-2 == "false"
expect resp.http.crlf-2 == "true"
expect resp.http.jchanged-2 == "true"
expect resp.http.empty-2 == "false"
expect resp.http.first-3 == "false"
expect resp.http.last-3 == "false"
expect resp.http.start-3 == "false"
expect resp.http.bsc-3 == "false"
expect resp.http.crlf-3 == "false"
expect resp.http.jchanged-3 == "false"
expect resp.http.empty-3 == "true"
} -run
......@@ -51,6 +51,18 @@ $Method STRING .sub(PRIV_CALL, PRIV_TASK, STRING subject, STRING replacement,
BOOL sub_extended=0, BOOL unknown_unset=0,
BOOL unset_empty=0)
$Method BOOL .info_bool(ENUM {ALLOW_EMPTY_CLASS, ANCHORED, ALT_BSUX,
ALT_CIRCUMFLEX, ALT_VERBNAMES, CASELESS,
DOLLAR_ENDONLY, DOTALL, DUPNAMES, EXTENDED,
FIRSTLINE, MATCH_UNSET_BACKREF, MULTILINE,
NEVER_BACKSLASH_C, NEVER_UCP, NEVER_UTF,
NO_AUTO_CAPTURE, NO_AUTO_POSSESS,
NO_DOTSTAR_ANCHOR, NO_START_OPTIMIZE,
NO_UTF_CHECK, UCP, UNGREEDY, USE_OFFSET_LIMIT,
UTF, HAS_FIRSTCODEUNIT, MATCH_ATSTART,
HAS_LASTCODEUNIT, HAS_BACKSLASHC, HAS_CRORLF,
JCHANGED, MATCH_EMPTY}, BOOL compiled=1)
$Method INT .info_int(ENUM {BACKREFMAX, CAPTURECOUNT, JITSIZE, MATCHLIMIT,
MAXLOOKBEHIND, MINLENGTH, RECURSIONLIMIT, SIZE})
......
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