tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Cookies and values with ':' in them
Date Thu, 16 Apr 2009 21:08:17 GMT
Andre-John Mas wrote:
> Hi,
> 
> The company I am working for is in the process of migrating from Tomcat
> 5.x.x to Tomcat5.5.27. In doing so we noticed that the any cookie value
> containing a colon will have the value trimmed up to before that
> character. This is new. A work around is to add quotes around the value,
> but we were hoping to avoid such changes:

Using a ':' in a v0 cookie is not legal. You have to use a v1 cookie
which is as simple as using:
cookie.setVersion(1);

5.5.28 will (hopefully - if it gets enough votes) an feature (enabled by
default) to automatically switch invalid v0 cookies to v1 cookies and
quote them.

Mark

> 
> To write:
> 
>     Cookie cookie = new
> Cookie("PROFILE_UPDATE_TS_X","2009-04-16T23:34:19Z"");
>     cookie.setSecure(true);
>     cookie.setPath("/");
>     response.addCookie(cookie);
> 
> To read:
> 
>     /**
>       * This is a convenience method for getting a cookie by name. If the
>       * cookie is not present in the request, a null value will be
> returned.
>       */
>      protected Cookie getCookie ( String cookieName, HttpServletRequest
> request ) {
>          Cookie[] cookies = request.getCookies();
>          for ( int i=0; i<cookies.length; i++ ) {
>              if ( cookies[i].getName().equals(cookieName) ) {
>                  return cookies[i];
>              }
>          }
>          return null;
>      }
> 
> This is certainly a regression.
> 
> André-John---------------------------------------------------------------------
> 
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message