[squid-users] matching a user agent with regex

From: Rolf Loudon <rolf_at_ses.tas.gov.au>
Date: Mon, 15 Nov 2010 15:53:42 +1100


I've been trying and failing to match the user agent string for the browser acl type. I would appreciate any help. I don't know exactly what squid sees as the user agent but a capture of the traffic shows the user agent header and I'm basing it on what I see there.

The complicating fact is that a simple substring search won't work as there are multiple browsers with the same string. I wish to match the Windows and Mac OS X version of Safari. Its user agent string is shown as:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5\r\n

Looking simply for "Safari" works but the same string is reported in Google's Chrome user-agent, which I don't want to match.

I've tried things like ".*Version.* Safari.*" and including [0-9] groups for the version numbers, all to no avail.

For comparison , on OS X:

Chrome sends:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7\r\n

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv: Gecko/2010081818 Camino/2.0.4 (like Firefox/3.0.19)\r\n

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\r\n

I could invert my ACL Logic and match on the other browsers but I'd prefer a more direct way.

Any suggestions much appreciated.


Received on Mon Nov 15 2010 - 04:53:54 MST

This archive was generated by hypermail 2.2.0 : Mon Nov 15 2010 - 12:00:02 MST