Skip to content

Commit 07d2fa3

Browse files
author
Stephane Landelle
committed
1 parent e058017 commit 07d2fa3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public static Cookie parseCookie(String value) {
460460
// favor 'max-age' field over 'expires'
461461
if (!maxAgeSet && "max-age".equalsIgnoreCase(f[0])) {
462462
try {
463-
maxAge = Integer.valueOf(removeQuote(f[1]));
463+
maxAge = Math.max(Integer.valueOf(removeQuote(f[1])), 0);
464464
} catch (NumberFormatException e1) {
465465
// ignore failure to parse -> treat as session cookie
466466
// invalidate a previously parsed expires-field
@@ -469,11 +469,11 @@ public static Cookie parseCookie(String value) {
469469
maxAgeSet = true;
470470
} else if (!maxAgeSet && !expiresSet && "expires".equalsIgnoreCase(f[0])) {
471471
try {
472-
maxAge = convertExpireField(f[1]);
472+
maxAge = Math.max(convertExpireField(f[1]), 0);
473473
} catch (Exception e) {
474474
// original behavior, is this correct at all (expires field with max-age semantics)?
475475
try {
476-
maxAge = Integer.valueOf(f[1]);
476+
maxAge = Math.max(Integer.valueOf(f[1]), 0);
477477
} catch (NumberFormatException e1) {
478478
// ignore failure to parse -> treat as session cookie
479479
}
@@ -487,10 +487,6 @@ public static Cookie parseCookie(String value) {
487487
}
488488
}
489489

490-
if (maxAge < -1) {
491-
maxAge = -1;
492-
}
493-
494490
return new Cookie(domain, cookieName, cookieValue, path, maxAge, secure);
495491
}
496492

0 commit comments

Comments
 (0)