Commit 0b0a0fee authored by Geoff Simmons's avatar Geoff Simmons

test UTF8 encoding with the extract() function

parent 2ccfa815
......@@ -284,3 +284,50 @@ client c1 {
expect resp.http.patternbytes == "fallback"
expect resp.http.patternchars == "z"
} -run
# extract() 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.extract("^.........$",
{"日扼語"}, "z");
set resp.http.threechars =
re2.extract("^...$",
{"日扼語"}, "z",
utf8=true);
set resp.http.bytes =
re2.extract({"日扼語"},
{"日扼語"}, "z");
set resp.http.chars =
re2.extract({"日扼語"},
{"日扼語"}, "z",
utf8=true);
set resp.http.patternbytes =
re2.extract({"^.扼.$"},
{"日扼語"}, "z",
fallback="fallback");
set resp.http.patternchars =
re2.extract({"^.扼.$"},
{"日扼語"}, "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