Commit 0e066bfa by Geoff Simmons

Add the match() function.

This brings about a major refactoring, to factor out common code for
regex compiles and matches.
parent 24056885
Pipeline #243 skipped
......@@ -38,6 +38,7 @@ CONTENTS
========
* regex(STRING, BOOL, BOOL, ENUM {ANYCRLF,UNICODE}, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, STRING, BOOL, INT, BOOL, BOOL, BOOL, BOOL, ENUM {CR,LF,CRLF,ANYCRLF,ANY}, BOOL, BOOL, BOOL, BOOL, BOOL, INT, BOOL, BOOL, BOOL, BOOL)
* BOOL match(PRIV_CALL, PRIV_TASK, STRING, STRING, BOOL, BOOL, ENUM {ANYCRLF,UNICODE}, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, STRING, BOOL, INT, BOOL, BOOL, BOOL, BOOL, ENUM {CR,LF,CRLF,ANYCRLF,ANY}, BOOL, BOOL, BOOL, BOOL, BOOL, INT, BOOL, BOOL, BOOL, BOOL, INT, INT, INT, BOOL, BOOL, BOOL, BOOL, BOOL, ENUM {HARD,SOFT}, INT)
* BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE})
* STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION})
* INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT})
......@@ -81,6 +82,15 @@ regex.namedref
STRING regex.namedref(STRING name, STRING fallback="**NAMEDREF METHOD FAILED**")
.. _func_match:
match
-----
::
BOOL match(PRIV_CALL, PRIV_TASK, STRING pattern, STRING subject, BOOL allow_empty_class=0, BOOL anchored=0, ENUM {ANYCRLF,UNICODE} bsr=0, BOOL alt_bsux=0, BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0, BOOL dollar_endonly=0, BOOL dotall=0, BOOL dupnames=0, BOOL extended=0, BOOL firstline=0, STRING locale=0, BOOL match_unset_backref=0, INT max_pattern_len=0, BOOL multiline=0, BOOL never_backslash_c=0, BOOL never_ucp=0, BOOL never_utf=0, ENUM {CR,LF,CRLF,ANYCRLF,ANY} newline=0, BOOL no_auto_capture=0, BOOL no_auto_possess=0, BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0, BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0, BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0, INT len=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, ENUM {HARD,SOFT} partial=0, INT recursion_limit=0)
.. _func_config_bool:
config_bool
......
......@@ -23,4 +23,29 @@ b"});
b"});
set resp.http.r2-4 = r2.match({"ab"});
set resp.http.r2-5 = r2.match({"a b"});
set resp.http.f1-1
= pcre2.match("a\R?b", bsr=ANYCRLF, subject={"a b"});
set resp.http.f1-2 = pcre2.match("a\R?b", bsr=ANYCRLF, subject={"a
b"});
set resp.http.f1-3 = pcre2.match("a\R?b", bsr=ANYCRLF, subject={"a
b"});
set resp.http.f1-4
= pcre2.match("a\R?b", bsr=ANYCRLF, subject={"ab"});
set resp.http.f1-5
= pcre2.match("a\R?b", bsr=ANYCRLF, subject={"a b"});
set resp.http.f2-1 = pcre2.match("a\R{2,4}b", bsr=ANYCRLF, subject={"a
b"});
set resp.http.f2-2 = pcre2.match("a\R{2,4}b", bsr=ANYCRLF, subject={"a
b"});
set resp.http.f2-3 = pcre2.match("a\R{2,4}b", bsr=ANYCRLF, subject={"a
b"});
set resp.http.f2-4
= pcre2.match("a\R{2,4}b", bsr=ANYCRLF, subject={"ab"});
set resp.http.f2-5
= pcre2.match("a\R{2,4}b", bsr=ANYCRLF, subject={"a b"});
}
......
# -*-mode: vcl; coding: raw-text -*-
# For the bsr=UNICODE test in compile_opts.vtc, to test the match
# function. Loaded via include, since vcl.inline, which is used by
# vtc, apparently changes \r characters to \n.
sub vcl_synth {
set resp.http.f1-1 = pcre2.match("^a\Rb", bsr=UNICODE, subject={"a
b"});
set resp.http.f1-2
= pcre2.match("^a\Rb", bsr=UNICODE, subject={"a b"});
set resp.http.f1-3 = pcre2.match("^a\Rb", bsr=UNICODE, subject={"a
b"});
set resp.http.f1-4
= pcre2.match("^a\Rb", bsr=UNICODE, subject={"a b"});
set resp.http.f1-5
= pcre2.match("^a\Rb", bsr=UNICODE, subject={"a b"});
set resp.http.f1-6
= pcre2.match("^a\Rb", bsr=UNICODE, subject={"ab"});
set resp.http.f1-7 = pcre2.match("^a\Rb", bsr=UNICODE, subject={"a
b"});
set resp.http.f2-1 = pcre2.match("^a\R*b", bsr=UNICODE, subject="ab");
set resp.http.f2-2 = pcre2.match("^a\R*b", bsr=UNICODE, subject={"a
b"});
set resp.http.f2-3
= pcre2.match("^a\R*b", bsr=UNICODE, subject={"a b"});
set resp.http.f2-4 = pcre2.match("^a\R*b", bsr=UNICODE, subject={"a
b"});
set resp.http.f2-5
= pcre2.match("^a\R*b", bsr=UNICODE, subject={"a b"});
set resp.http.f2-6
= pcre2.match("^a\R*b", bsr=UNICODE, subject={"a b"});
set resp.http.f2-7
= pcre2.match("^a\R*b", bsr=UNICODE, subject={"ab"});
set resp.http.f2-8 = pcre2.match("^a\R*b", bsr=UNICODE, subject={"a
b"});
set resp.http.f2-9 = pcre2.match("^a\R*b", bsr=UNICODE, subject={"a
b"});
set resp.http.f3-1 = pcre2.match("^a\R+b", bsr=UNICODE, subject={"a
b"});
set resp.http.f3-2
= pcre2.match("^a\R+b", bsr=UNICODE, subject={"a b"});
set resp.http.f3-3 = pcre2.match("^a\R+b", bsr=UNICODE, subject={"a
b"});
set resp.http.f3-4
= pcre2.match("^a\R+b", bsr=UNICODE, subject={"a b"});
set resp.http.f3-5
= pcre2.match("^a\R+b", bsr=UNICODE, subject={"a b"});
set resp.http.f3-6
= pcre2.match("^a\R+b", bsr=UNICODE, subject={"ab"});
set resp.http.f3-7 = pcre2.match("^a\R+b", bsr=UNICODE, subject={"a
b"});
set resp.http.f3-8 = pcre2.match("^a\R+b", bsr=UNICODE, subject={"a
b"});
set resp.http.f3-9 = pcre2.match("^a\R+b", bsr=UNICODE, subject="ab");
set resp.http.f4-1 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-2 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-3 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-4
= pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-5
= pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-6 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-7 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-8 = pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a
b"});
set resp.http.f4-9
= pcre2.match("^a\R{1,3}b", bsr=UNICODE, subject={"a "});
}
......@@ -1007,3 +1007,63 @@ varnish v1 -errvcl {vmod pcre2 error: Cannot compile '(?z)abc' in r constructor:
new r = pcre2.regex("(?z)abc");
}
}
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.f1 = pcre2.match("ab\idef", "");
set resp.http.f2 = pcre2.match("(?X)ab\idef", "");
set resp.http.f3 = pcre2.match("x{5,4}", "");
set resp.http.f4 = pcre2.match("z{65536}", "");
set resp.http.f5 = pcre2.match("[abcd", "");
set resp.http.f6 = pcre2.match("[\B]", "");
set resp.http.f7 = pcre2.match("[z-a]", "");
set resp.http.f8 = pcre2.match("^*", "");
set resp.http.f9 = pcre2.match("(abc", "");
set resp.http.f10 = pcre2.match("(?# abc", "");
set resp.http.f11 = pcre2.match("(?z)abc", "");
return(deliver);
}
}
logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod pcre2 error: Cannot compile 'ab.idef' in pcre2.match..: unrecognized character follows . at offset 3$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '..X.ab.idef' in pcre2.match..: unrecognized character after .. or ..- at offset 2$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile 'x.5.4.' in pcre2.match..: numbers out of order in .. quantifier at offset 5$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile 'z.65536.' in pcre2.match..: number too big in .. quantifier at offset 7$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '.abcd' in pcre2.match..: missing terminating . for character class at offset 5$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '..B.' in pcre2.match..: invalid escape sequence in character class at offset 2$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '.z-a.' in pcre2.match..: range out of order in character class at offset 3$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '..' in pcre2.match..: quantifier does not follow a repeatable item at offset 1$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '.abc' in pcre2.match..: missing closing parenthesis at offset 4$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '..# abc' in pcre2.match..: missing . after ..# comment at offset 7$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '....abc' in pcre2.match..: unrecognized character after .. or ..- at offset 2$"
expect * = End
} -start
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.f1 == "false"
expect resp.http.f2 == "false"
expect resp.http.f3 == "false"
expect resp.http.f4 == "false"
expect resp.http.f5 == "false"
expect resp.http.f6 == "false"
expect resp.http.f7 == "false"
expect resp.http.f8 == "false"
expect resp.http.f9 == "false"
expect resp.http.f10 == "false"
expect resp.http.f11 == "false"
} -run
logexpect l1 -wait
......@@ -43,3 +43,43 @@ varnish v1 -vcl {
new r = pcre2.regex(".", never_ucp=true, never_utf=true);
}
}
# compiling patterns in the match function
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.f1 = pcre2.match(subject="Ä", pattern=
"[^ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸŹŻŽƁƂƄƆƇƉƊƋƎƏƐƑƓƔƖƗƘƜƝƟƠƢƤƦƧƩƬƮƯƱƲƳƵƷƸƼDŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶǷǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺȻȽȾɁΆΈΉΊΌΎΏΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫϒϓϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹϺϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸԀԂԄԆԈԊԌԎԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸἈἉἊἋἌἍἎἏἘἙἚἛἜἝἨἩἪἫἬἭἮἯἸἹἺἻἼἽἾἿὈὉὊὋὌὍὙὛὝὟὨὩὪὫὬὭὮὯᾸᾹᾺΆῈΈῊΉῘῙῚΊῨῩῪΎῬῸΌῺΏabcdefghijklmnopqrstuvwxyzªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķĸĺļľŀłńņňʼnŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżžſƀƃƅƈƌƍƒƕƙƚƛƞơƣƥƨƪƫƭưƴƶƹƺƽƾƿdžljnjǎǐǒǔǖǘǚǜǝǟǡǣǥǧǩǫǭǯǰdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȡȣȥȧȩȫȭȯȱȳȴȵȶȷȸȹȼȿɀɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϐϑϕϖϗϙϛϝϟϡϣϥϧϩϫϭϯϰϱϲϳϵϸϻϼабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӷӹԁԃԅԇԉԋԍԏաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚẛạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹἀἁἂἃἄἅἆἇἐἑἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀὁὂὃὄὅὐὑὒὓὔὕὖὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷιῂῃῄῆῇῐῑῒΐῖῗῠῡῢΰῤῥῦῧῲῳῴῶῷⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣⳤⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥfffiflffifflſtstﬓﬔﬕﬖﬗ\d-_^]");
set resp.http.f2 = pcre2.match(".", "", utf=true);
set resp.http.f3 = pcre2.match(".", "", ucp=true);
set resp.http.f4
= pcre2.match(".", "x", never_ucp=true, never_utf=true);
return(deliver);
}
}
logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '.' in pcre2.match..: this version of PCRE2 does not have Unicode support at offset 0$"
expect * = VCL_Error "^vmod pcre2 error: Cannot compile '.' in pcre2.match..: this version of PCRE2 does not have Unicode support at offset 0$"
expect * = End
} -start
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.f1 == "false"
expect resp.http.f2 == "false"
expect resp.http.f3 == "false"
expect resp.http.f4 == "true"
} -run
logexpect l1 -wait
......@@ -14,4 +14,16 @@ sub vcl_synth {
def"});
set resp.http.r4 = r4.match({"abc
def"});
set resp.http.f1-1 = pcre2.match("^12.34", dotall=true, subject={"12
34"});
set resp.http.f2-1 = pcre2.match("^12.34", {"12
34"});
set resp.http.f1-2
= pcre2.match("^12.34", dotall=true, subject={"12 34"});
set resp.http.f2-2 = pcre2.match("^12.34", {"12 34"});
set resp.http.f3 = pcre2.match("\A.*\Z", dotall=true, subject={"abc
def"});
set resp.http.f4 = pcre2.match("\A.*\Z", {"abc
def"});
}
......
......@@ -84,3 +84,76 @@ client c1 {
expect resp.http.r14-1 == "true"
expect resp.http.r14-2 == "false"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.f1
= pcre2.match("^[\w]+", "cole", locale="fr_FR");
set resp.http.f2 = pcre2.match("^[\w]+", "cole");
set resp.http.f3
= pcre2.match("^[\W]+", "cole", locale="fr_FR");
set resp.http.f4 = pcre2.match("^[\W]+", "cole");
set resp.http.f5-1 = pcre2.match("[\b]", "", locale="fr_FR");
set resp.http.f6-1 = pcre2.match("[\b]", "");
set resp.http.f5-2 = pcre2.match("[\b]", "a", locale="fr_FR");
set resp.http.f6-2 = pcre2.match("[\b]", "a", locale="fr_FR");
set resp.http.f7 = pcre2.match("^\w+", "cole", locale="fr_FR");
set resp.http.f8 = pcre2.match("^\w+", "cole");
set resp.http.f9
= pcre2.match("(.+)\b(.+)", "cole", locale="fr_FR");
set resp.http.f10 = pcre2.match("(.+)\b(.+)", "cole");
set resp.http.f11-1
= pcre2.match("cole", "cole", locale="fr_FR",
caseless=true);
set resp.http.f12-1
= pcre2.match("cole", "cole", caseless=true);
set resp.http.f11-2
= pcre2.match("cole", "cole", locale="fr_FR",
caseless=true);
set resp.http.f12-2
= pcre2.match("cole", "cole", caseless=true);
set resp.http.f13-1
= pcre2.match("^[\xc8-\xc9]", "cole", locale="fr_FR",
caseless=true);
set resp.http.f13-2
= pcre2.match("^[\xc8-\xc9]", "cole", locale="fr_FR",
caseless=true);
set resp.http.f14-1
= pcre2.match("^[\xc8-\xc9]", "cole", locale="fr_FR");
set resp.http.f14-2
= pcre2.match("^[\xc8-\xc9]", "cole", locale="fr_FR");
}
}
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.f1 == "true"
expect resp.http.f2 == "false"
expect resp.http.f3 == "false"
expect resp.http.f4 == "true"
expect resp.http.f5-1 == "true"
expect resp.http.f5-2 == "false"
expect resp.http.f6-1 == "true"
expect resp.http.f6-2 == "false"
expect resp.http.f7 == "true"
expect resp.http.f8 == "false"
expect resp.http.f9 == "false"
expect resp.http.f10 == "true"
expect resp.http.f11-1 == "true"
expect resp.http.f11-2 == "true"
expect resp.http.f12-1 == "true"
expect resp.http.f12-2 == "false"
expect resp.http.f13-1 == "true"
expect resp.http.f13-2 == "true"
expect resp.http.f14-1 == "true"
expect resp.http.f14-2 == "false"
} -run
......@@ -33,6 +33,12 @@ varnish v1 -vcl+backend {
if (empty.match(beresp.http.foo)) {
set beresp.http.bar = "YYY";
}
if (pcre2.match("$", beresp.http.bar)) {
set beresp.http.foo-f = "XXX";
}
if (pcre2.match("", beresp.http.foo)) {
set beresp.http.bar-f = "YYY";
}
}
} -start
......@@ -44,4 +50,6 @@ client c1 -repeat 2 {
expect resp.http.bar-native == "YYY"
expect resp.http.foo == "XXX"
expect resp.http.bar == "YYY"
expect resp.http.foo-f == "XXX"
expect resp.http.bar-f == "YYY"
} -run
......@@ -31,6 +31,8 @@ varnish v1 -vcl {
sub vcl_synth {
set resp.http.r1 = r.match("defabc");
set resp.http.r2 = r.match("defabc", len=3);
set resp.http.r1-f = pcre2.match("abc", "defabc");
set resp.http.r2-f = pcre2.match("abc", "defabc", len=3);
}
} -start
......@@ -61,6 +63,12 @@ varnish v1 -vcl {
set resp.http.r1-2 = r1.match("defabc", anchored=true);
set resp.http.r2-1 = r2.match("Mississippi");
set resp.http.r2-2 = r2.match("Mississippi", anchored=true);
set resp.http.r1-1f = pcre2.match("abc", "defabc");
set resp.http.r1-2f
= pcre2.match("abc", "defabc", anchored=true);
set resp.http.r2-1f = pcre2.match("\Biss\B", "Mississippi");
set resp.http.r2-2f
= pcre2.match("\Biss\B", "Mississippi", anchored=true);
}
}
......@@ -72,6 +80,10 @@ client c1 -repeat 2 {
expect resp.http.r1-2 == "false"
expect resp.http.r2-1 == "true"
expect resp.http.r2-2 == "false"
expect resp.http.r1-1f == "true"
expect resp.http.r1-2f == "false"
expect resp.http.r2-1f == "true"
expect resp.http.r2-2f == "false"
} -run
# notbol
......@@ -90,6 +102,8 @@ varnish v1 -vcl {
sub vcl_synth {
set resp.http.r1 = r.match("XABC");
set resp.http.r2 = r.match("XABC", notbol=true);
set resp.http.r1-f = pcre2.match("^X", "XABC");
set resp.http.r2-f = pcre2.match("^X", "XABC", notbol=true);
}
}
......@@ -99,6 +113,8 @@ client c1 -repeat 2 {
expect resp.status == "200"
expect resp.http.r1 == "true"
expect resp.http.r2 == "false"
expect resp.http.r1-f == "true"
expect resp.http.r2-f == "false"
} -run
# noteol
......@@ -121,6 +137,12 @@ varnish v1 -vcl {
set resp.http.r3 = r.match("a", noteol=true);
set resp.http.r4 = r.match(noteol=true, subject={"a
"});
set resp.http.r1-f = pcre2.match("a$", "a");
set resp.http.r2-f = pcre2.match("a$", {"a
"});
set resp.http.r3-f = pcre2.match("a$", "a", noteol=true);
set resp.http.r4-f = pcre2.match("a$", noteol=true, subject={"a
"});
}
}
......@@ -132,6 +154,10 @@ client c1 -repeat 2 {
expect resp.http.r2 == "true"
expect resp.http.r3 == "false"
expect resp.http.r4 == "false"
expect resp.http.r1-f == "true"
expect resp.http.r2-f == "true"
expect resp.http.r3-f == "false"
expect resp.http.r4-f == "false"
} -run
# notempty
......@@ -156,6 +182,13 @@ varnish v1 -vcl {
set resp.http.r2-2 = r2.match("", notempty=true);
set resp.http.r3-1 = r3.match("");
set resp.http.r3-2 = r3.match("c", notempty=true);
set resp.http.r1-1f = pcre2.match("a?b?", "");
set resp.http.r1-2f = pcre2.match("a?b?", "", notempty=true);
set resp.http.r2-1f = pcre2.match("|-", "");
set resp.http.r2-2f = pcre2.match("|-", "", notempty=true);
set resp.http.r3-1f = pcre2.match("(?>(*ACCEPT)b)c", "");
set resp.http.r3-2f
= pcre2.match("(?>(*ACCEPT)b)c", "c", notempty=true);
}
}
......@@ -169,6 +202,12 @@ client c1 -repeat 2 {
expect resp.http.r2-2 == "false"
expect resp.http.r3-1 == "true"
expect resp.http.r3-2 == "false"
expect resp.http.r1-1f == "true"
expect resp.http.r1-2f == "false"
expect resp.http.r2-1f == "true"
expect resp.http.r2-2f == "false"
expect resp.http.r3-1f == "true"
expect resp.http.r3-2f == "false"
} -run
# notempty_atstart
......@@ -189,6 +228,12 @@ varnish v1 -vcl {
set resp.http.r2 = r.match("xyz", notempty_atstart=true);
set resp.http.r3 = r.match("xyzabc");
set resp.http.r4 = r.match("xyzabc", notempty_atstart=true);
set resp.http.r1f = pcre2.match("^a?b?", "xyz");
set resp.http.r2f
= pcre2.match("^a?b?", "xyz", notempty_atstart=true);
set resp.http.r3f = pcre2.match("^a?b?", "xyzabc");
set resp.http.r4f
= pcre2.match("^a?b?", "xyzabc", notempty_atstart=true);
}
}
......@@ -200,4 +245,8 @@ client c1 -repeat 2 {
expect resp.http.r2 == "false"
expect resp.http.r3 == "true"
expect resp.http.r4 == "false"
expect resp.http.r1f == "true"
expect resp.http.r2f == "false"
expect resp.http.r3f == "true"
expect resp.http.r4f == "false"
} -run
# -*-mode: vcl; coding: raw-text -*-
# For the newline test in compile_opts.vtc. Loaded via include, since
# vcl.inline, which is used by vtc, apparently changes \r characters
# to \n.
# For the newline test with the match method in
# compile_opts.vtc. Loaded via include, since vcl.inline, which is
# used by vtc, apparently changes \r characters to \n.
sub vcl_synth {
set resp.http.r1-1 = r1.match({"xyz
abc"});
......
# -*-mode: vcl; coding: raw-text -*-
# For the newline test with the match function in
# compile_opts.vtc. Loaded via include, since vcl.inline, which is
# used by vtc, apparently changes \r characters to \n.
sub vcl_synth {
set resp.http.f1-1
= pcre2.match("^abc", newline=LF, multiline=true, subject={"xyz
abc"});
set resp.http.f1-2
= pcre2.match("^abc", newline=LF, multiline=true, subject={"xyz
abc"});
set resp.http.f1-3
= pcre2.match("^abc", newline=LF, multiline=true,
subject={"xyz abc"});
set resp.http.f1-4
= pcre2.match("^abc", newline=LF, multiline=true,
subject={"xyzabc "});
set resp.http.f1-5
= pcre2.match("^abc", newline=LF, multiline=true,
subject={"xyzabc pqr"});
set resp.http.f1-6
= pcre2.match("^abc", newline=LF, multiline=true,
subject={"xyzabc
"});
set resp.http.f1-7
= pcre2.match("^abc", newline=LF, multiline=true,
subject={"xyzabc
pqr"});
set resp.http.f2-1
= pcre2.match("^abc", newline=CRLF, multiline=true, subject={"xyz
abclf>"});
set resp.http.f2-2
= pcre2.match("^abc", newline=CRLF, multiline=true, subject={"xyz
abclf"});
set resp.http.f2-3
= pcre2.match("^abc", newline=CRLF, multiline=true,
subject={"xyz abclf"});
set resp.http.f3-1
= pcre2.match("^abc", newline=CR, multiline=true,
subject={"xyz abc"});
set resp.http.f3-2
= pcre2.match("^abc", newline=CR, multiline=true, subject={"xyz
abc"});
set resp.http.f3-3
= pcre2.match("^abc", newline=CR, multiline=true, subject={"xyz
abc"});
set resp.http.f4-1 = pcre2.match("^a.b", newline=LF, subject={"a b"});
set resp.http.f4-2 = pcre2.match("^a.b", newline=LF, subject={"a
b"});
set resp.http.f5-1 = pcre2.match("^a.b", newline=CR, subject={"a
b"});
set resp.http.f5-2 = pcre2.match("^a.b", newline=CR, subject={"a b"});
set resp.http.f6-1
= pcre2.match("^a.b", newline=ANYCRLF, subject={"ab"});
set resp.http.f6-2
= pcre2.match("^a.b", newline=ANYCRLF, subject={"a b"});
set resp.http.f7-1 = pcre2.match("^a.b", newline=ANY, subject={"a
b"});
set resp.http.f7-2 = pcre2.match("^a.b", newline=ANY, subject={"a b"});
set resp.http.f7-3
= pcre2.match("^a.b", newline=ANY, subject={"ab"});
}
......@@ -44,6 +44,26 @@ $Method STRING .backref(INT ref, STRING fallback = "**BACKREF METHOD FAILED**")
$Method STRING .namedref(STRING name,
STRING fallback = "**NAMEDREF METHOD FAILED**")
$Function BOOL match(PRIV_CALL, PRIV_TASK, STRING pattern, STRING subject,
BOOL allow_empty_class=0, BOOL anchored=0,
ENUM {ANYCRLF, UNICODE} bsr=0, BOOL alt_bsux=0,
BOOL alt_circumflex=0, BOOL alt_verbnames=0,
BOOL caseless=0, BOOL dollar_endonly=0, BOOL dotall=0,
BOOL dupnames=0, BOOL extended=0, BOOL firstline=0,
STRING locale=0, BOOL match_unset_backref=0,
INT max_pattern_len=0, BOOL multiline=0,
BOOL never_backslash_c=0, BOOL never_ucp=0,
BOOL never_utf=0,
ENUM {CR, LF, CRLF, ANYCRLF, ANY} newline=0,
BOOL no_auto_capture=0, BOOL no_auto_possess=0,
BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0,
BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0,
BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0,
INT len=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,
ENUM {HARD, SOFT} partial=0, INT recursion_limit=0)
$Function BOOL config_bool(ENUM {JIT, STACKRECURSE, UNICODE})
$Function STRING config_str(ENUM {BSR, JITTARGET, NEWLINE, UNICODE_VERSION,
......
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