Problem with case-insensitive (?i) regex

Krzysztof Dajka alteriks at gmail.com
Sat Dec 4 16:35:21 CET 2010


Hi,
I'm trying to make case-insensitive regex to catch mobile browsers and
redirect them to lightweight version of web page.
I found this doc:
http://www.varnish-cache.org/docs/2.1/faq/general.html?highlight=insensitive

But using "?i" before regular expression makes VCL compiler complain:

storage_malloc: max size 200 MB.
Message from VCC-compiler:
Regexp compilation error:

nothing to repeat

(/exp/config/rewrite_UA.vcl Line 2 Pos 30)
  if ( req.http.User-Agent ~ "?iOpera Mini" )
 -----------------------------##############--
Running VCC-compiler failed, exit 1
VCL compilation failed

Here is my vcl snippet: (If I remove "?i" in front of every regex
compilation goes fine)

sub vcl_recv {
  if (
      req.http.User-Agent ~ "?iOpera Mini" ||
      req.http.User-Agent ~ "?iSymbianOS" ||
      req.http.User-Agent ~ "?iSymbian OS" ||
      req.http.User-Agent ~ "?iWindows CE" ||
      req.http.User-Agent ~ "?iBlackBerry" ||
      req.http.User-Agent ~ "?iNetFront" ||
      req.http.User-Agent ~ "?iPalm OS" ||
      req.http.User-Agent ~ "?iBlazer" ||
      req.http.User-Agent ~ "?iElaine" ||
      req.http.User-Agent ~ "?i^WAP" ||
      req.http.User-Agent ~ "?iPlucker" ||
      req.http.User-Agent ~ "?iiPhone" ||
      req.http.User-Agent ~ "?iiPod" ||
      req.http.User-Agent ~ "?iAndroid" ||
      req.http.User-Agent ~ "?iMIDP"
      )
      { error 701; }
}




More information about the varnish-misc mailing list