Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-selector
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-selector
Commits
3178d443
Commit
3178d443
authored
Jun 26, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement case-insensitive .match().
parent
92ef0fa9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
812 additions
and
2 deletions
+812
-2
case.vtc
src/tests/case.vtc
+778
-0
vmod_selector.c
src/vmod_selector.c
+34
-2
No files found.
src/tests/case.vtc
0 → 100644
View file @
3178d443
# looks like -*- vcl -*-
varnishtest "case insensitve matches"
varnish v1 -vcl {
import ${vmod_selector};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new t = selector.set(case_sensitive=false);
t.add("foo");
t.add("bar");
t.add("baz");
t.add("quux");
t.add("foobar");
}
sub vcl_recv {
return (synth(200));
}
sub vcl_synth {
set resp.http.Match-Foo = t.match("FOO");
set resp.http.Match-Bar = t.match("BAR");
set resp.http.Match-Baz = t.match("BAZ");
set resp.http.Match-Quux = t.match("QUUX");
set resp.http.Match-Foobar = t.match("FOOBAR");
set resp.http.Match-Oof = t.match("OOF");
set resp.http.Match-Rab = t.match("RAB");
set resp.http.Match-Zab = t.match("ZAB");
set resp.http.Match-Xuuq = t.match("XUUQ");
set resp.http.Match-Raboof = t.match("RABOOF");
return (deliver);
}
} -start
client c1 {
txreq
rxresp
expect resp.http.Match-Foo == "true"
expect resp.http.Match-Bar == "true"
expect resp.http.Match-Baz == "true"
expect resp.http.Match-Quux == "true"
expect resp.http.Match-Foobar == "true"
expect resp.http.Match-Oof == "false"
expect resp.http.Match-Rab == "false"
expect resp.http.Match-Zab == "false"
expect resp.http.Match-Xuuq == "false"
expect resp.http.Match-Raboof == "false"
} -run
varnish v1 -vcl {
import ${vmod_selector};
import std;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
# 100 random choices from /usr/share/dict/words
new s = selector.set(case_sensitive=false);
s.add("unsuccessful");
s.add("bogeyman's");
s.add("prelude");
s.add("Dniester");
s.add("brunet");
s.add("overseer");
s.add("choral's");
s.add("Tadzhikistan");
s.add("Becket");
s.add("rancor");
s.add("exterminating");
s.add("cancan's");
s.add("cockiness's");
s.add("approves");
s.add("Sallie's");
s.add("varlet's");
s.add("gestates");
s.add("ranter");
s.add("Lancelot's");
s.add("apathetically");
s.add("apprentice");
s.add("Cooper");
s.add("fifth's");
s.add("inquietude");
s.add("Gibraltar's");
s.add("Moss");
s.add("cowing");
s.add("European");
s.add("pressmen");
s.add("espousal's");
s.add("hysterically");
s.add("jellied");
s.add("ibuprofen's");
s.add("graphologists");
s.add("mindfulness");
s.add("patriot");
s.add("infernal");
s.add("sell");
s.add("phoebe");
s.add("musicologists");
s.add("hatching's");
s.add("scrimmaged");
s.add("griddlecake");
s.add("RAF's");
s.add("Bostonian");
s.add("evacuate");
s.add("Burns");
s.add("expiating");
s.add("fission");
s.add("fixates");
s.add("grouper");
s.add("highborn");
s.add("damply");
s.add("smuggling");
s.add("droppings's");
s.add("emptiest");
s.add("phantasms");
s.add("archaeological");
s.add("vigilante's");
s.add("upturn's");
s.add("hussar's");
s.add("Buddhisms");
s.add("animators");
s.add("overused");
s.add("coccus");
s.add("porterhouse");
s.add("succulent");
s.add("truncates");
s.add("girt's");
s.add("mornings");
s.add("seats");
s.add("Hafiz's");
s.add("reprieve");
s.add("superintends");
s.add("defeatism's");
s.add("harps");
s.add("prospecting");
s.add("Delaney's");
s.add("vitriolic");
s.add("huddles");
s.add("fusible");
s.add("forking");
s.add("immersed");
s.add("chairlifts");
s.add("dillydallying");
s.add("unreasonableness's");
s.add("McLuhan");
s.add("anvils");
s.add("tapes");
s.add("yardsticks");
s.add("scribbler");
s.add("conceivably");
s.add("deprived");
s.add("scripting");
s.add("galley");
s.add("invasive");
s.add("percolates");
s.add("Millie");
s.add("mil's");
s.add("dethrones");
}
sub vcl_recv {
return (synth(200));
}
sub vcl_synth {
std.timestamp("BeforeMatch");
set resp.http.Match = s.match(req.http.Word);
std.timestamp("AfterMatch");
}
}
client c1 {
# The same word list in reverse order, and randomly chosen
# case for each letter.
txreq -hdr "Word: dEThRONEs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: Mil's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: mILlIE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: pERcOlATEs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: inVASIvE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: GALley"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: sCRIpTiNG"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: dEpRIveD"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: cONCeiVaBLy"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SCribbLeR"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: YARdstIcKs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: TaPes"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: AnVilS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: mcLuhaN"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: unreAsONaBlEnEsS'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: DIlLydalLYIng"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ChAIRLIfts"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: imMeRSeD"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: FOrKINg"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: FusiblE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: HUdDLES"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: vitriolic"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: dELANEy'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: prOspectINg"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: hArPS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: DEFEatisM'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: sUperinteNDS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: repRIEVE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: hAfIz'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SeATS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: moRNIngS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: giRT's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: TrUNcATES"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SuCcULenT"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: PorTErHOuse"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: cOCcUS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: oveRuSEd"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ANimAtORs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: BuDDhiSms"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: huSSAr'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: uPTurN's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: VIgILaNte'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ArcHAeoLOgIcAl"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: PhAnTAsMs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: EmPTiEsT"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: drOPPiNgS's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SmUGgLiNg"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: DAmpLy"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: HIgHboRN"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: GROuPER"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: FIxaTEs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: FissIOn"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: exPIAtING"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: BUrNS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: EVACuAtE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: BosTonIaN"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: raF's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: grIddLeCAKE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SCRimMAGEd"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: HatcHInG'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: MUSIcOlOGiSts"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: pHOeBe"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: SElL"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: inFErNAl"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: PAtRiOt"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: mINDfuLNEss"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: GRaphOlOGISTS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ibuprOFeN's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: jElLIeD"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: hYStERIcalLY"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: espOUSal'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: prEssmeN"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: eUrOPean"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: cowInG"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: moSS"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: gibralTAR's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: iNQUIeTUDE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: FiFth'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: CooPEr"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: aPpRENtice"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ApATheTIcAlLy"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: LAnCelot's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: RANTer"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: GeStaTEs"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: vARleT'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: sALliE'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ApPrOVES"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: cocKinesS'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: CanCaN's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: eXTERmInatiNG"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: rANCOR"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: bEcKEt"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: tAdZhIkiStan"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: ChoRAl's"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: OVErseER"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: BrUNEt"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: dnieSTER"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: pRelUdE"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: bogEymAn'S"
rxresp
expect resp.http.Match == "true"
txreq -hdr "Word: unSuCCeSSFUl"
rxresp
expect resp.http.Match == "true"
# 100 random words generated with pwgen.
txreq -hdr "Word: oozahdoo6U"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: uzoi1Cew8D"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Sah4iexah5"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aShiengih1"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: sei6eJuza9"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: coe4reeKaa"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: xaiqu4cohV"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Zoh8NeeD6I"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: thu3us9Aic"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: hooTii9toi"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: zah6eng7Ue"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Iesee5shir"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Saewux0the"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: uomang8Aeg"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ieh8Egotee"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: useePooHa8"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aequohH5sh"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ahgaCohth3"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Gohfahxae2"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: yaiXei5the"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ek3Eiruk1l"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: taeBah0Epe"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: kahk6ashuK"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aiBeet6AeK"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Eenoquu4Pe"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: iogh7ONge3"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Eepholuth2"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: xa3aevee9B"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: queu9ex6Ae"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: OongeiN0fo"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: uos1Iifi3O"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: phua8ohSee"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: dahThi2vo4"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ahThung7fo"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: opahH0Yaeg"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Jeev0dier9"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ub4dahShae"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: thaewe4Rah"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: chei6jei4A"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: eimeeW4yei"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Echohf8Iwa"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: eike7aez9V"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aemahdah0Z"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Iogh3ve9ah"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: the1ciDio0"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ug4uobeiBe"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: yiebaip6Fi"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Phuirilie4"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: TahtaeNg9e"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Shaixit5IT"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aik2QuooTh"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ath3Ohbich"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: fei8Oogia7"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ohbee2aThe"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Hei2chilai"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ahj4ohT2go"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ado3gaeChu"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Aiphuaj3ui"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Cheiloow5o"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: oofaPhai8y"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: der0Ii0aev"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: oQu1wiu8ne"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Rei5oThoze"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: mujahJae5t"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Oht5la3omu"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aequaifa7O"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ubee2iehio"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Thae8aiku1"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ieTae3aiXa"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ATh9sei4li"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aghieh0Phe"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: AeVe1jahfu"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ooChah1hee"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: RaoKaeR1id"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: saihahh0Xa"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: puoLaesae2"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: euw1Laicij"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Fah7ak0Aeh"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: eeghohZo2e"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: noS8Uvee8a"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: kizai5Kong"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: aiph9tai1U"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: sie8arieW4"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: eaHohhoo1i"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: de6chooy0I"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ceimae7jae"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: fu7heeH0Oh"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Ido7cheiD8"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Aipao6vie5"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Zumoos2ait"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: eiTe6oobiz"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: Gufa9xa4ru"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: gan9Exiuzu"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ogee6Veer6"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: etu4Igohra"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: saitai2Nei"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ahDoobi7Ah"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: ICoe2aiqui"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: xiyieJeir6"
rxresp
expect resp.http.Match == "false"
txreq -hdr "Word: lahya5Rae6"
rxresp
expect resp.http.Match == "false"
} -run
src/vmod_selector.c
View file @
3178d443
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <ctype.h>
#include "cache/cache.h"
#include "cache/cache.h"
#include "vcl.h"
#include "vcl.h"
...
@@ -65,6 +66,7 @@ struct vmod_selector_set {
...
@@ -65,6 +66,7 @@ struct vmod_selector_set {
#define VMOD_SELECTOR_SET_MAGIC 0x838979ef
#define VMOD_SELECTOR_SET_MAGIC 0x838979ef
struct
entry
**
table
;
struct
entry
**
table
;
char
**
members
;
char
**
members
;
char
**
lomembers
;
struct
pt_y
*
origo
;
struct
pt_y
*
origo
;
char
*
vcl_name
;
char
*
vcl_name
;
unsigned
nmembers
;
unsigned
nmembers
;
...
@@ -146,6 +148,7 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set, VCL_STRING member,
...
@@ -146,6 +148,7 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set, VCL_STRING member,
vre_t
*
re
=
NULL
;
vre_t
*
re
=
NULL
;
const
char
*
error
;
const
char
*
error
;
int
erroffset
;
int
erroffset
;
char
**
members
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_SELECTOR_SET_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_SELECTOR_SET_MAGIC
);
...
@@ -169,9 +172,20 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set, VCL_STRING member,
...
@@ -169,9 +172,20 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set, VCL_STRING member,
AN
(
set
->
members
);
AN
(
set
->
members
);
set
->
members
[
n
-
1
]
=
strdup
(
member
);
set
->
members
[
n
-
1
]
=
strdup
(
member
);
AN
(
set
->
members
[
n
-
1
]);
AN
(
set
->
members
[
n
-
1
]);
members
=
set
->
members
;
if
(
!
set
->
case_sensitive
)
{
set
->
lomembers
=
realloc
(
set
->
members
,
n
*
sizeof
(
VCL_STRING
));
AN
(
set
->
lomembers
);
set
->
lomembers
[
n
-
1
]
=
strdup
(
member
);
AN
(
set
->
lomembers
[
n
-
1
]);
for
(
char
*
m
=
set
->
lomembers
[
n
-
1
];
*
m
;
m
++
)
*
m
=
tolower
(
*
m
);
members
=
set
->
lomembers
;
}
errno
=
0
;
errno
=
0
;
if
(
PT_Insert
(
&
set
->
origo
,
n
-
1
,
set
->
members
)
!=
0
)
{
if
(
PT_Insert
(
&
set
->
origo
,
n
-
1
,
members
)
!=
0
)
{
if
(
errno
==
EINVAL
)
if
(
errno
==
EINVAL
)
VFAIL
(
ctx
,
"%s.add():
\"
%s
\"
added more than once"
,
VFAIL
(
ctx
,
"%s.add():
\"
%s
\"
added more than once"
,
set
->
vcl_name
,
member
);
set
->
vcl_name
,
member
);
...
@@ -240,6 +254,8 @@ vmod_set_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject)
...
@@ -240,6 +254,8 @@ vmod_set_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject)
{
{
unsigned
idx
;
unsigned
idx
;
struct
match_data
*
match
;
struct
match_data
*
match
;
char
**
members
;
const
char
*
subj
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_SELECTOR_SET_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_SELECTOR_SET_MAGIC
);
...
@@ -255,8 +271,24 @@ vmod_set_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject)
...
@@ -255,8 +271,24 @@ vmod_set_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject)
return
(
0
);
return
(
0
);
}
}
members
=
set
->
members
;
subj
=
subject
;
if
(
!
set
->
case_sensitive
)
{
char
*
copy
;
if
((
copy
=
WS_Copy
(
ctx
->
ws
,
subject
,
-
1
))
==
NULL
)
{
VERRNOMEM
(
ctx
,
"%s.match(): copying subject for "
"case-insensitive match"
,
set
->
vcl_name
);
return
(
0
);
}
for
(
char
*
c
=
copy
;
*
c
;
c
++
)
*
c
=
tolower
(
*
c
);
subj
=
copy
;
members
=
set
->
lomembers
;
}
match
=
get_match_data
(
ctx
,
set
,
"match"
);
match
=
get_match_data
(
ctx
,
set
,
"match"
);
if
((
idx
=
PT_Lookup
(
set
->
origo
,
set
->
members
,
subject
))
==
UINT_MAX
)
{
if
((
idx
=
PT_Lookup
(
set
->
origo
,
members
,
subj
))
==
UINT_MAX
)
{
match
->
n
=
0
;
match
->
n
=
0
;
return
(
0
);
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