Varnish regular expression regsuball to uppercase (support Replacement Text Case Conversion)

217 Views Asked by At

I am looking for proper handling of URLs in Varnish (5.2.1), here is what I do (trying to redirect to lowercase URLs):

set req.url = std.tolower(req.url); //this is new.url
//if original.url != new.url => redirect

This produce good URL, until client library (and there are quite few) where they convert %[hex] to %[HEX] according https://www.rfc-editor.org/rfc/rfc3986#section-2.1 end up in URL redirection loop.

Example:

req.url = "/query=mythbusters%20-%20die%20wissensj%c3%A4ger"
is redirected to
"/query=mythbusters%20-%20die%20wissensj%c3%a4ger"
and client redirects it to 
"/query=mythbusters%20-%20die%20wissensj%c3%A4ger"

I am trying to solve this issue, using regular expressions, but for some reason, I can not get UPPER case results, according PCRE/PCRE2/Perl regexp it should be possible like this:

set req.url = std.tolower(req.url);
set req.url = regsuball(req.url, "(%[0-9a-f][0-9a-f])", "\U\1");

Anybody have idea how to solve this ?

1

There are 1 best solutions below

0
On

I posted issue on Varnish github, answer was this is not supported.