fix formatting and change comment flags to attributes
Signed-off-by: Bruce MacDonald <brucewmacdonald@gmail.com>
This commit is contained in:
parent
6ad148c8f9
commit
a1bb3b4491
|
@ -47,12 +47,14 @@ public class HttpCookie
|
|||
NONE("None"), STRICT("Strict"), LAX("Lax");
|
||||
|
||||
private String attributeValue;
|
||||
SameSite(String attributeValue) {
|
||||
|
||||
SameSite(String attributeValue)
|
||||
{
|
||||
this.attributeValue = attributeValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String getAttributeValue()
|
||||
{
|
||||
return this.attributeValue;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +129,7 @@ public class HttpCookie
|
|||
_comment = cookie.getComment();
|
||||
_version = cookie.getVersion();
|
||||
_expiration = _maxAge < 0 ? -1 : System.nanoTime() + TimeUnit.SECONDS.toNanos(_maxAge);
|
||||
// TODO support for SameSite values has not yet been added to java.net.HttpCookie
|
||||
// support for SameSite values has not yet been added to java.net.HttpCookie
|
||||
_sameSite = getSameSiteFromComment(cookie.getComment());
|
||||
}
|
||||
|
||||
|
@ -414,7 +416,7 @@ public class HttpCookie
|
|||
if (_sameSite != null)
|
||||
{
|
||||
buf.append("; SameSite=");
|
||||
buf.append(_sameSite.toString());
|
||||
buf.append(_sameSite.getAttributeValue());
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
|
@ -446,7 +448,7 @@ public class HttpCookie
|
|||
return null;
|
||||
}
|
||||
|
||||
public static String getCommentWithoutFlags(String comment)
|
||||
public static String getCommentWithoutAttributes(String comment)
|
||||
{
|
||||
if (comment == null)
|
||||
{
|
||||
|
|
|
@ -212,10 +212,10 @@ public class HttpCookieTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getCommentWithoutFlags()
|
||||
public void getCommentWithoutAttributes()
|
||||
{
|
||||
assertEquals(HttpCookie.getCommentWithoutFlags("comment__SAME_SITE_NONE__"), "comment");
|
||||
assertEquals(HttpCookie.getCommentWithoutFlags("comment__HTTP_ONLY____SAME_SITE_NONE__"), "comment");
|
||||
assertNull(HttpCookie.getCommentWithoutFlags("__SAME_SITE_LAX__"));
|
||||
assertEquals(HttpCookie.getCommentWithoutAttributes("comment__SAME_SITE_NONE__"), "comment");
|
||||
assertEquals(HttpCookie.getCommentWithoutAttributes("comment__HTTP_ONLY____SAME_SITE_NONE__"), "comment");
|
||||
assertNull(HttpCookie.getCommentWithoutAttributes("__SAME_SITE_LAX__"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class Response implements HttpServletResponse
|
|||
// HttpOnly was supported as a comment in cookie flags before the java.net.HttpCookie implementation so need to check that
|
||||
boolean httpOnly = cookie.isHttpOnly() || HttpCookie.isHttpOnlyInComment(comment);
|
||||
SameSite sameSite = HttpCookie.getSameSiteFromComment(comment);
|
||||
comment = HttpCookie.getCommentWithoutFlags(comment);
|
||||
comment = HttpCookie.getCommentWithoutAttributes(comment);
|
||||
|
||||
addCookie(new HttpCookie(
|
||||
cookie.getName(),
|
||||
|
|
Loading…
Reference in New Issue