Hi, 

I need help filtering multiple cookies from the Cookie header, when some values 
in the Cookie contain commas.

An example of such a Cookie might be:

Cookie: foo1A=value1; Date=Sat, 18 May 2019; foo2B=value2;  baz=value3; eek=a, 
ook=b; AB01p45

The characters after foo could be any valid substring, and there could be 
multiple foo* instances in the header.

I need to filter out foo*, such that the output Cookie will be:

Cookie: Date=Sat, 18 May 2019; baz=value3; eek=a, ook=b; AB01p45

Things I’ve tried so far:

- Using replace-header with req.fhdr(Cookie).  
  But it didn’t replace all the instances of foo*, just the first one.  (Maybe 
I didn’t give the correct regex)    
- Using regsub() with set-header.  It can’t deal with commas.  
- I thought of url-encoding the header, then using regsub(), and then 
url-decoding it back using set-var variables, but there’s no url_enc converter. 
     
- Similarly, there’s a hex converted but no inverse of it.    
- I finally used Lua to solve the problem, but I’d prefer to use a non-Lua 
solution. 

How can I solve this problem?

Thanks,
C

P.S.   I believe that commas should not be sent in the Cookie header (they are 
valid in Set-Cookie), but I don’t control what the client sends. 

Reply via email to