Fixed a problem where the value of commentURL and port is not double-quoted
This commit is contained in:
parent
9c8106948e
commit
ede8316642
@ -104,16 +104,17 @@ public class CookieEncoder {
|
|||||||
|
|
||||||
if (encodingVersion == 2) {
|
if (encodingVersion == 2) {
|
||||||
if (cookie.getCommentURL() != null) {
|
if (cookie.getCommentURL() != null) {
|
||||||
add(sb, CookieHeaderNames.COMMENTURL, QueryStringEncoder.encodeComponent(cookie.getCommentURL(), charset));
|
addQuoted(sb, CookieHeaderNames.COMMENTURL, QueryStringEncoder.encodeComponent(cookie.getCommentURL(), charset));
|
||||||
}
|
}
|
||||||
if(!cookie.getPorts().isEmpty()) {
|
if(!cookie.getPorts().isEmpty()) {
|
||||||
sb.append(CookieHeaderNames.PORT);
|
sb.append(CookieHeaderNames.PORT);
|
||||||
sb.append((char) HttpCodecUtil.EQUALS);
|
sb.append((char) HttpCodecUtil.EQUALS);
|
||||||
|
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||||
for (int port: cookie.getPorts()) {
|
for (int port: cookie.getPorts()) {
|
||||||
sb.append(port);
|
sb.append(port);
|
||||||
sb.append((char) HttpCodecUtil.COMMA);
|
sb.append((char) HttpCodecUtil.COMMA);
|
||||||
}
|
}
|
||||||
sb.setLength(sb.length() - 1); // Remove the trailing comma.
|
sb.setCharAt(sb.length() - 1, (char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||||
}
|
}
|
||||||
if (cookie.isDiscard()) {
|
if (cookie.isDiscard()) {
|
||||||
@ -132,6 +133,15 @@ public class CookieEncoder {
|
|||||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addQuoted(StringBuffer sb, String name, String val) {
|
||||||
|
sb.append(name);
|
||||||
|
sb.append((char) HttpCodecUtil.EQUALS);
|
||||||
|
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||||
|
sb.append(val);
|
||||||
|
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||||
|
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||||
|
}
|
||||||
|
|
||||||
private void add(StringBuffer sb, String name, int val) {
|
private void add(StringBuffer sb, String name, int val) {
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
sb.append((char) HttpCodecUtil.EQUALS);
|
sb.append((char) HttpCodecUtil.EQUALS);
|
||||||
|
@ -68,6 +68,8 @@ class HttpCodecUtil {
|
|||||||
*/
|
*/
|
||||||
static final byte COMMA = 44;
|
static final byte COMMA = 44;
|
||||||
|
|
||||||
|
static final byte DOUBLE_QUOTE = '"';
|
||||||
|
|
||||||
private HttpCodecUtil() {
|
private HttpCodecUtil() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user