Index: httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java (revision 3e484c083064c7718f694d870aca2448e40adcc5) +++ httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java (date 1587039726882) @@ -27,6 +27,8 @@ package org.apache.hc.client5.http.impl.cookie; +import static org.junit.Assert.fail; + import java.util.Calendar; import java.util.Date; @@ -82,7 +84,7 @@ final CookieAttributeHandler h = new LaxMaxAgeHandler(); try { h.parse(null, "stuff"); - Assert.fail("NullPointerException must have been thrown"); + fail("NullPointerException must have been thrown"); } catch (final NullPointerException ex) { // expected } @@ -115,6 +117,18 @@ Assert.assertEquals(0, c.get(Calendar.MILLISECOND)); } + @Test + public void testParseExpiryInvalidTime0() { + final BasicClientCookie cookie = new BasicClientCookie("name", "value"); + final CookieAttributeHandler h = new LaxExpiresHandler(); + try { + h.parse(cookie, null); + } catch (final MalformedCookieException neverThrown) { + fail("MalformedCookieException will never be thrown."); + } + Assert.assertNull(cookie.getExpiryDate()); + } + @Test(expected = MalformedCookieException.class) public void testParseExpiryInvalidTime1() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); Index: httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java (revision 3e484c083064c7718f694d870aca2448e40adcc5) +++ httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java (date 1587036987785) @@ -43,6 +43,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.message.ParserCursor; import org.apache.hc.core5.util.Args; +import org.apache.hc.core5.util.TextUtils; /** * Cookie {@code expires} attribute handler conformant to the more relaxed interpretation @@ -107,6 +108,9 @@ @Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); + if (TextUtils.isBlank(value)) { + return; + } final ParserCursor cursor = new ParserCursor(0, value.length()); final StringBuilder content = new StringBuilder();