From: <rb...@us...> - 2014-03-25 19:41:48
|
Revision: 9205 http://sourceforge.net/p/htmlunit/code/9205 Author: rbri Date: 2014-03-25 19:41:44 +0000 (Tue, 25 Mar 2014) Log Message: ----------- Cookies: Some fixes for the parsing of the expires date in IE11. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2014-03-25 19:28:46 UTC (rev 9204) +++ trunk/htmlunit/src/changes/changes.xml 2014-03-25 19:41:44 UTC (rev 9205) @@ -8,6 +8,9 @@ <body> <release version="2.15" date="???" description="Bugfixes"> + <action type="fix" dev="rbri"> + Cookies: Some fixes for the parsing of the expires date in IE11. + </action> <action type="fix" dev="asashour" issue="1577"> HttpWebConnection: socket reuse (regression in 2.14). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2014-03-25 19:28:46 UTC (rev 9204) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2014-03-25 19:41:44 UTC (rev 9205) @@ -634,6 +634,13 @@ @BrowserFeature(@WebBrowser(IE)) HTML_OBJECT_CLASSID, + /** Indicates that the start date for two digits cookies is 1970 + * instead of 2000 (Two digits years are interpreted as 20xx + * if before 1970 and as 19xx otherwise). + */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, maxVersion = 10) }) + HTTP_COOKIE_START_DATE_1970, + /** Indicates that "host" HTTP header should be the first. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTTP_HEADER_HOST_FIRST, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2014-03-25 19:28:46 UTC (rev 9204) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2014-03-25 19:41:44 UTC (rev 9205) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTTP_COOKIE_START_DATE_1970; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTTP_HEADER_HOST_FIRST; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.URL_AUTH_CREDENTIALS; @@ -148,7 +149,8 @@ htmlUnitCookieSpecProvider_ = new CookieSpecProvider() { @Override public CookieSpec create(final HttpContext context) { - return new HtmlUnitBrowserCompatCookieSpec(webClient_.getIncorrectnessListener()); + return new HtmlUnitBrowserCompatCookieSpec(webClient.getBrowserVersion(), + webClient_.getIncorrectnessListener()); } }; httpContext_ = new HttpClientContext(); @@ -792,7 +794,8 @@ "d/M/yyyy", }; - HtmlUnitBrowserCompatCookieSpec(final IncorrectnessListener incorrectnessListener) { + HtmlUnitBrowserCompatCookieSpec(final BrowserVersion browserVersion, + final IncorrectnessListener incorrectnessListener) { super(); final BasicPathHandler pathHandler = new BasicPathHandler() { @Override @@ -814,7 +817,12 @@ value = value.substring(1, value.length() - 1); } value = value.replaceAll("[ ,:-]+", " "); - cookie.setExpiryDate(DateUtils.parseDate(value, DEFAULT_DATE_PATTERNS, DATE_1_1_1970)); + + Date startDate = null; + if (browserVersion.hasFeature(HTTP_COOKIE_START_DATE_1970)) { + startDate = DATE_1_1_1970; + } + cookie.setExpiryDate(DateUtils.parseDate(value, DEFAULT_DATE_PATTERNS, startDate)); } public boolean match(final Cookie cookie, final CookieOrigin origin) { |