Re: Haproxy Reg Exps ...

From: Brane F. Gračnar <brane.gracnar#najdi.si>
Date: Tue, 7 Jun 2011 01:47:33 +0200


On Monday 06 of June 2011 11:56:05 Georgi Georgiev wrote:
> Hi to all ,
> Yesterday I’ve try to match on regexp from client user-agent and
> redirect it ..
>
> The configuration is on frontend is like this:
> ……
> acl test_match hdr_reg -i user\-agent:\
> test|android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobil
> e|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\
> os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|
> vodafone|wap|windows\ (ce|phone)|xda|xiino
>
> redirect prefix http://xxxxxxx?rule1 if test_match
> …….
>
> It is working fine for most of PCs and mobiles ( redirect only mobile )
> but with exactly this user-agent :
>
> Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6.6;
> SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET4.0C; .NET CLR
> 3.0.30729)
>
> ( IE 8 with Vista SP2 ) it somehow match rule ……
>
> So the question is :
> Where can I find some info about regular expressions library used in
> haproxy ? I need to find out why it match in this very case …..

$ haproxy -vv | grep -i options
  OPTIONS = USE_LINUX_SPLICE=1 USE_LIBCRYPT=1 USE_REGPARM=1 USE_PCRE=1 USE_STATIC_PCRE=1 You're using libpcre if USE_PCRE=1.

You can check pcre regex with grep -P (it doesn't match on my machine):

$ echo "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6.6; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET4.0C; .NET CLR 3.0.30729)" | grep -P 'test|android|avantgo|blackberry|blazer|compal|elaine| fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\. (browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino'

$ echo $?
1

Best regards, Brane Received on 2011/06/07 01:47

This archive was generated by hypermail 2.2.0 : 2011/06/07 02:00 CEST