Fixed a problem where CookieDecoder doesn't strip surrounding quotes for certain values
This commit is contained in:
parent
1912bfc81d
commit
a26d1e4392
@ -95,6 +95,7 @@ public class CookieDecoder {
|
|||||||
comment = QueryStringDecoder.decodeComponent(value, charset);
|
comment = QueryStringDecoder.decodeComponent(value, charset);
|
||||||
}
|
}
|
||||||
else if (CookieHeaderNames.COMMENTURL.equalsIgnoreCase(name)) {
|
else if (CookieHeaderNames.COMMENTURL.equalsIgnoreCase(name)) {
|
||||||
|
value = trimSurroundingQuotes(value);
|
||||||
commentURL = QueryStringDecoder.decodeComponent(value, charset);
|
commentURL = QueryStringDecoder.decodeComponent(value, charset);
|
||||||
}
|
}
|
||||||
else if (CookieHeaderNames.DOMAIN.equalsIgnoreCase(name)) {
|
else if (CookieHeaderNames.DOMAIN.equalsIgnoreCase(name)) {
|
||||||
@ -113,6 +114,7 @@ public class CookieDecoder {
|
|||||||
version = Integer.valueOf(value);
|
version = Integer.valueOf(value);
|
||||||
}
|
}
|
||||||
else if (CookieHeaderNames.PORT.equalsIgnoreCase(name)) {
|
else if (CookieHeaderNames.PORT.equalsIgnoreCase(name)) {
|
||||||
|
value = trimSurroundingQuotes(value);
|
||||||
String[] portList = value.split(COMMA);
|
String[] portList = value.split(COMMA);
|
||||||
ports = new int[portList.length];
|
ports = new int[portList.length];
|
||||||
for (int i1 = 0; i1 < portList.length; i1++) {
|
for (int i1 = 0; i1 < portList.length; i1++) {
|
||||||
@ -144,4 +146,17 @@ public class CookieDecoder {
|
|||||||
}
|
}
|
||||||
return cookies;
|
return cookies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String trimSurroundingQuotes(String value) {
|
||||||
|
if (value.length() >= 2) {
|
||||||
|
char firstChar = value.charAt(0);
|
||||||
|
char lastChar = value.charAt(value.length() - 1);
|
||||||
|
if ((firstChar == '"' || firstChar == '\'') &&
|
||||||
|
(lastChar == '"' || lastChar == '\'')) {
|
||||||
|
// Strip surrounding quotes.
|
||||||
|
value = value.substring(1, value.length() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user