Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004767 [Quercus] block always 09-18-11 15:09 09-21-11 08:37
Reporter krystian View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version 4.0.14
Summary 0004767: Array cookies are not read properly
Description Reading a cookie like name[index] doesn't work in Resin/Quercus.
When sending a cookie name[index] instead of being processed and put into array variable using index to set the value, a variable named 'name[index]' is set the value. It should behave as described in [^] and [^] (about reading cookies). It seems that the place where the functionality is missed is [^] method, which doesn't distinguish cookies whose names contain square brackets, so it does not treat them as arrays, but just as normal (flat) variables.
Additional Information In fact it happens in 4.0.19+
Attached Files  issue0004767.patch [^] (2,818 bytes) 09-21-11 08:37

- Relationships

- Notes
09-18-11 15:13

You might check this behaviour comparing Resin/Quercus and normal/standard PHP by using this PHP script on server-side:

$arrayIdx = 31337;
if(array_key_exists($name, $_COOKIE) && array_key_exists($arrayIdx, $_COOKIE[$name]))
  echo "behaving like normal PHP";
if(array_key_exists($name.'['.$arrayIdx.']', $_COOKIE))
  echo "behaving like Resin";

and sending HTTP request to this script and setting required cookie - as in this example:

private static final String COOKIE_NAME = "ARRAY-COOKIE-TEST";
private static final int ARRAY_INDEX = 31337;
private static final String COOKIE_VALUE = "test-value";

public void testTracker() throws Exception {
  HttpClientParams params = new HttpClientParams();
  HttpClient client = new HttpClient(params);
  HostConfiguration config = new HostConfiguration();

  HttpHost host = new HttpHost("", 80,

  HttpMethod method = new GetMethod("/array-cookie-test.php");
  method.addRequestHeader("Cookie", COOKIE_NAME + "[" + ARRAY_INDEX
    + "]=" + COOKIE_VALUE + "; expires=Fri, 29-Sep-2012 15:03:21 GMT; path=/");
09-19-11 14:17

One point to note - multidimensional arrays should be supported - [^] -> Storing Arrays
09-20-11 11:46
edited on: 09-20-11 11:47

Another update on cookies spec version and their interoperability between Java and other platforms/languages (I might be good to be aware of it - as Resin/Quercus is to be interoperable between Java and PHP worlds) - especially comments in: [^] [^]

resulting in org.glassfish.web.rfc2109_cookie_names_enforced settings property in different implementations of javax.servlet.http.Cookie

Worth mentioning is also a rather juicy discussion around Tomcat's approach to cookies in: [^]

09-21-11 08:37

Please find attached a patch which fixes the described issue. The patch has been made against the trunk version. I might be missing formatter settings in Eclipse (as the formatter_profile=_caucho in .settings doesn't seem to be available in your SVN's trunk), so I would need to ask you to reformat the code with your formatter settings just after applying the patch.


- Issue History
Date Modified Username Field Change
09-18-11 15:09 krystian New Issue
09-18-11 15:13 krystian Note Added: 0005511
09-18-11 15:22 krystian Issue Monitored: krystian
09-19-11 14:17 krystian Note Added: 0005517
09-20-11 11:46 krystian Note Added: 0005519
09-20-11 11:47 krystian Note Edited: 0005519
09-21-11 08:37 krystian Note Added: 0005522
09-21-11 08:37 krystian File Added: issue0004767.patch

Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
37 total queries executed.
28 unique queries executed.
Powered by Mantis Bugtracker