From: <asa...@us...> - 2017-07-19 13:38:27
|
Revision: 14670 http://sourceforge.net/p/htmlunit/code/14670 Author: asashour Date: 2017-07-19 13:38:25 +0000 (Wed, 19 Jul 2017) Log Message: ----------- Fix Location header if it has non-ASCII characters Issue 1898 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-07-19 12:22:37 UTC (rev 14669) +++ trunk/htmlunit/src/changes/changes.xml 2017-07-19 13:38:25 UTC (rev 14670) @@ -8,6 +8,9 @@ <body> <release version="2.28" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1898"> + Fix Location header if it has non-ASCII characters. + </action> <action type="fix" dev="rbri"> JavaScript: fix ClassCastException in Array.from. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-07-19 12:22:37 UTC (rev 14669) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-07-19 13:38:25 UTC (rev 14670) @@ -20,6 +20,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SUPPORT_VIA_ACTIVEXOBJECT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.URL_MINIMAL_QUERY_ENCODING; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.WINDOW_EXECUTE_EVENTS; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.UTF_8; import java.io.BufferedInputStream; @@ -1419,6 +1420,7 @@ if (locationString == null) { return webResponse; } + locationString = new String(locationString.getBytes(ISO_8859_1), UTF_8); newUrl = expandUrl(url, locationString); } catch (final MalformedURLException e) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2017-07-19 12:22:37 UTC (rev 14669) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2017-07-19 13:38:25 UTC (rev 14670) @@ -157,7 +157,6 @@ * @throws Exception if an error occurs */ @Test - @NotYetImplemented public void locationUTF() throws Exception { final String response = "HTTP/1.1 302 Found\r\n" + "Content-Length: 0\r\n" |