mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-28 19:09:10 +00:00
276545 Quoted cookie paths
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@357 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
963fd5da81
commit
ad4ed67de2
@ -8,6 +8,7 @@ jetty-7.0.0.M3-SNAPSHOT
|
||||
+ Portable continuations for jetty6 and servlet3
|
||||
+ Refactored continuations to only support response wrapping
|
||||
+ Added ContinuationThrowable
|
||||
+ 276545 Quoted cookie paths
|
||||
+ 279725 Support 100 and 102 expectations
|
||||
|
||||
jetty-7.0.0.M2 18 May 2009
|
||||
|
@ -274,7 +274,7 @@ public class HttpFields
|
||||
|
||||
|
||||
|
||||
public final static String __01Jan1970 = formatDate(0);
|
||||
public final static String __01Jan1970 = formatDate(0).trim();
|
||||
public final static Buffer __01Jan1970_BUFFER = new ByteArrayBuffer(__01Jan1970);
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
@ -979,12 +979,15 @@ public class HttpFields
|
||||
if (path != null && path.length() > 0)
|
||||
{
|
||||
buf.append(";Path=");
|
||||
buf.append(URIUtil.encodePath(path));
|
||||
if (path.trim().startsWith("\""))
|
||||
buf.append(path);
|
||||
else
|
||||
QuotedStringTokenizer.quoteIfNeeded(buf,path);
|
||||
}
|
||||
if (domain != null && domain.length() > 0)
|
||||
{
|
||||
buf.append(";Domain=");
|
||||
buf.append(domain.toLowerCase());// lowercase for IE
|
||||
QuotedStringTokenizer.quoteIfNeeded(buf,domain.toLowerCase());
|
||||
}
|
||||
|
||||
if (maxAge >= 0)
|
||||
|
@ -28,21 +28,21 @@ import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HttpHeaderTest extends TestCase
|
||||
public class HttpFieldsTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for HttpHeaderTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public HttpHeaderTest(String arg0)
|
||||
public HttpFieldsTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
junit.textui.TestRunner.run(HttpHeaderTest.class);
|
||||
junit.textui.TestRunner.run(HttpFieldsTest.class);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -375,7 +375,22 @@ public class HttpHeaderTest extends TestCase
|
||||
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("close")).getOrdinal()>=0);
|
||||
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")).getOrdinal()>=0);
|
||||
}
|
||||
|
||||
|
||||
public void testSetCookie()
|
||||
throws Exception
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.addSetCookie("minimal","value",null,null,-1,null,false,false,-1);
|
||||
assertEquals("minimal=value",fields.getStringField("Set-Cookie"));
|
||||
|
||||
fields.clear();
|
||||
fields.addSetCookie("everything","value","domain","path",0,"comment",true,true,0);
|
||||
assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01 Jan 1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
|
||||
|
||||
fields.clear();
|
||||
fields.addSetCookie("ev erything","va lue","do main","pa th",1,"co mment",true,true,2);
|
||||
assertEquals("\"ev erything\"=\"va lue\";Version=2;Comment=\"co mment\";Path=\"pa th\";Domain=\"do main\";Max-Age=1;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
|
||||
}
|
||||
|
||||
private Set enum2set(Enumeration e)
|
||||
{
|
@ -503,7 +503,7 @@ public class QuotedStringTokenizer
|
||||
/** Quote a string into a StringBuffer.
|
||||
* The characters ", \, \n, \r, \t, \f, \b are escaped.
|
||||
* Quotes are forced if any escaped characters are present or there
|
||||
* is a ", ', space, + or % character.
|
||||
* is a ", ', space, +, =, ; or % character.
|
||||
*
|
||||
* @param buf The StringBuffer
|
||||
* @param s The String to quote.
|
||||
@ -529,6 +529,8 @@ public class QuotedStringTokenizer
|
||||
case '%':
|
||||
case '+':
|
||||
case ' ':
|
||||
case ';':
|
||||
case '=':
|
||||
e=i;
|
||||
buf.append('"');
|
||||
// TODO when 1.4 support is dropped: buf.append(s,0,e);
|
||||
@ -611,6 +613,8 @@ public class QuotedStringTokenizer
|
||||
case '%':
|
||||
case '+':
|
||||
case ' ':
|
||||
case ';':
|
||||
case '=':
|
||||
e=i;
|
||||
buf.append('"');
|
||||
// TODO when 1.4 support is dropped: buf.append(s,0,e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user