regsub() odd behaviour in varnish-3.0.4-r2 on ubuntu-14.04 LTS

psihozefir psihozefir at yahoo.com
Wed Jul 15 08:12:30 CEST 2015


Hello!
I run a varnish installation and I encountered an odd behaviour when trying to get a cookie and its value using regsub(); here is the code:
vcl_hash() {[...]hash_data(regsub(req.http.cookie,"(LoggedIn=[^;]+;)","\1"));[...]return(hash)
}
The LoggedIn cookie takes integer values depending on the user type and there are multiple user types (or groups).The regex should match only the cookie name, followed by the equal sign, followed by the user type value and finally followed by semicolon and then return the matched string.
What varnish does instead is it returns an arbirarily truncated cookie:56 Hash         c ASP.NET_SessionId=piejvbp31o4cbdsbzak55j2c; LoggedIn=0; __utma=203440913.1436939550.; __utmb=203440913.; __utmc=20913; __utmz=203440913..utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
(Note: I manually truncated/edited __utm* cookies' values intentionally.)
What am I doing wrong, or what should I know more about regsub() to be able to return the intended string?I tested the regex on regex101.com and it works correctly there.
Thank you for your help!Sorin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150715/65329851/attachment.html>


More information about the varnish-misc mailing list