Commit 7cec7c4a authored by Geoff Simmons's avatar Geoff Simmons

test the encoding option in the sub() function, and fix a test of

the match() function
parent dfc8c459
......@@ -82,7 +82,8 @@ varnish v1 -vcl {
set resp.http.bytesf = "match";
}
if (re2.match({"日扼語"},
{"日扼語"})) {
{"日扼語"},
utf8=true)) {
set resp.http.charsf = "match";
}
if (re2.match({"^.扼.$"},
......@@ -189,3 +190,50 @@ client c1 {
expect resp.http.patternbytes == <undef>
expect resp.http.patternchars == "match"
} -run
# sub() function
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.ninebytes =
re2.sub("^.........$",
{"日扼語"}, "z");
set resp.http.threechars =
re2.sub("^...$",
{"日扼語"}, "z",
utf8=true);
set resp.http.bytes =
re2.sub({"日扼語"},
{"日扼語"}, "z");
set resp.http.chars =
re2.sub({"日扼語"},
{"日扼語"}, "z",
utf8=true);
set resp.http.patternbytes =
re2.sub({"^.扼.$"},
{"日扼語"}, "z",
fallback="fallback");
set resp.http.patternchars =
re2.sub({"^.扼.$"},
{"日扼語"}, "z",
utf8=true);
}
}
client c1 {
txreq
rxresp
expect resp.http.ninebytes == "z"
expect resp.http.threechars == "z"
expect resp.http.bytes == "z"
expect resp.http.chars == "z"
expect resp.http.patternbytes == "fallback"
expect resp.http.patternchars == "z"
} -run
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