Skip to content

Commit ec96261

Browse files
committed
[UNDERTOW-2741] Allow support to quoted legacy attributes in Cookie client headers
Signed-off-by: Flavia Rainone <frainone@redhat.com>
1 parent 1f2c12d commit ec96261

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎core/src/main/java/io/undertow/util/Cookies.java‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,13 @@ private static void storeCookie(final CookieJar cookieJar ) {
419419
}
420420
}
421421

422+
private static String stripQuotes(String value) {
423+
if (value.charAt(0) == '"' && value.charAt(value.length() -1) == '"') {
424+
return value.substring(1, value.length() -1);
425+
}
426+
return value;
427+
}
428+
422429
private static void createCookie(final String value, final CookieJar cookieJar) {
423430
if (cookieJar.parsedCookies.size() > cookieJar.maxCookies) {
424431
throw UndertowMessages.MESSAGES.tooManyCookies(cookieJar.maxCookies);
@@ -433,12 +440,13 @@ private static void createCookie(final String value, final CookieJar cookieJar)
433440
}
434441

435442
if (!cookieJar.name.isEmpty() && cookieJar.name.charAt(0) == '$') {
443+
final String noQuotesValue = stripQuotes(value);
436444
if (cookieJar.name.equals(VERSION)) {
437-
cookieJar.version = Integer.parseInt(value);
445+
cookieJar.version = Integer.parseInt(noQuotesValue);
438446
//Theoretically this should happen only once at the start
439-
applyAdditional(cookieJar, cookieJar.name, value);
447+
applyAdditional(cookieJar, cookieJar.name, noQuotesValue);
440448
} else if(cookieJar.currentCookie != null) {
441-
applyAdditional(cookieJar, cookieJar.name, value);
449+
applyAdditional(cookieJar, cookieJar.name, noQuotesValue);
442450
}
443451
} else {
444452
storeCookie(cookieJar);

0 commit comments

Comments
 (0)