You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(30) |
Sep
(15) |
Oct
(26) |
Nov
(12) |
Dec
(17) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(7) |
Feb
(27) |
Mar
(73) |
Apr
(17) |
May
(17) |
Jun
(78) |
Jul
(67) |
Aug
(60) |
Sep
(89) |
Oct
(140) |
Nov
(173) |
Dec
(46) |
2004 |
Jan
(39) |
Feb
(7) |
Mar
(21) |
Apr
(31) |
May
(13) |
Jun
(86) |
Jul
(14) |
Aug
(14) |
Sep
(53) |
Oct
(184) |
Nov
(186) |
Dec
(319) |
2005 |
Jan
(336) |
Feb
(274) |
Mar
(226) |
Apr
(102) |
May
(196) |
Jun
(130) |
Jul
(119) |
Aug
(143) |
Sep
(76) |
Oct
(85) |
Nov
(70) |
Dec
(159) |
2006 |
Jan
(125) |
Feb
(100) |
Mar
(80) |
Apr
(39) |
May
(55) |
Jun
(58) |
Jul
(50) |
Aug
(76) |
Sep
(55) |
Oct
(101) |
Nov
(163) |
Dec
(85) |
2007 |
Jan
(56) |
Feb
(53) |
Mar
(180) |
Apr
(221) |
May
(290) |
Jun
(199) |
Jul
(322) |
Aug
(515) |
Sep
(121) |
Oct
(297) |
Nov
(177) |
Dec
(103) |
2008 |
Jan
(516) |
Feb
(315) |
Mar
(586) |
Apr
(615) |
May
(197) |
Jun
(381) |
Jul
(390) |
Aug
(195) |
Sep
(603) |
Oct
(499) |
Nov
(622) |
Dec
(350) |
2009 |
Jan
(313) |
Feb
(338) |
Mar
(507) |
Apr
(317) |
May
(197) |
Jun
(375) |
Jul
(235) |
Aug
(424) |
Sep
(410) |
Oct
(338) |
Nov
(286) |
Dec
(306) |
2010 |
Jan
(367) |
Feb
(339) |
Mar
(371) |
Apr
(172) |
May
(233) |
Jun
(264) |
Jul
(421) |
Aug
(110) |
Sep
(218) |
Oct
(189) |
Nov
(185) |
Dec
(168) |
2011 |
Jan
(145) |
Feb
(213) |
Mar
(205) |
Apr
(64) |
May
(159) |
Jun
(67) |
Jul
(104) |
Aug
(126) |
Sep
(144) |
Oct
(106) |
Nov
(154) |
Dec
(225) |
2012 |
Jan
(111) |
Feb
(87) |
Mar
(131) |
Apr
(102) |
May
(180) |
Jun
(160) |
Jul
(412) |
Aug
(315) |
Sep
(311) |
Oct
(369) |
Nov
(464) |
Dec
(284) |
2013 |
Jan
(343) |
Feb
(165) |
Mar
(174) |
Apr
(120) |
May
(153) |
Jun
(134) |
Jul
(202) |
Aug
(105) |
Sep
(228) |
Oct
(332) |
Nov
(192) |
Dec
(219) |
2014 |
Jan
(348) |
Feb
(194) |
Mar
(189) |
Apr
(188) |
May
(297) |
Jun
(206) |
Jul
(79) |
Aug
(279) |
Sep
(111) |
Oct
(159) |
Nov
(61) |
Dec
(78) |
2015 |
Jan
(152) |
Feb
(145) |
Mar
(239) |
Apr
(223) |
May
(248) |
Jun
(296) |
Jul
(172) |
Aug
(189) |
Sep
(338) |
Oct
(217) |
Nov
(131) |
Dec
(184) |
2016 |
Jan
(118) |
Feb
(221) |
Mar
(414) |
Apr
(412) |
May
(303) |
Jun
(133) |
Jul
(129) |
Aug
(121) |
Sep
(136) |
Oct
(67) |
Nov
(89) |
Dec
(245) |
2017 |
Jan
(349) |
Feb
(90) |
Mar
(328) |
Apr
(430) |
May
(284) |
Jun
(199) |
Jul
(164) |
Aug
(120) |
Sep
(57) |
Oct
(105) |
Nov
(108) |
Dec
(146) |
2018 |
Jan
(85) |
Feb
(48) |
Mar
(97) |
Apr
(62) |
May
(64) |
Jun
(136) |
Jul
(123) |
Aug
(87) |
Sep
(17) |
Oct
(27) |
Nov
(9) |
Dec
(16) |
2019 |
Jan
(9) |
Feb
(17) |
Mar
(18) |
Apr
(14) |
May
(8) |
Jun
|
Jul
(6) |
Aug
(12) |
Sep
(5) |
Oct
|
Nov
(2) |
Dec
|
2020 |
Jan
(8) |
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2023 |
Jan
|
Feb
(6) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <rb...@us...> - 2018-07-19 19:07:53
|
Revision: 15489 http://sourceforge.net/p/htmlunit/code/15489 Author: rbri Date: 2018-07-19 19:07:50 +0000 (Thu, 19 Jul 2018) Log Message: ----------- next step in our endless encoding fight Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlEmbed.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlEmbed.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlEmbed.java 2018-07-19 18:26:06 UTC (rev 15488) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlEmbed.java 2018-07-19 19:07:50 UTC (rev 15489) @@ -64,6 +64,7 @@ final URL url = page.getFullyQualifiedUrl(getAttributeDirect("src")); final WebRequest request = new WebRequest(url); + request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); final WebResponse webResponse = webclient.loadWebResponse(request); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java 2018-07-19 18:26:06 UTC (rev 15488) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java 2018-07-19 19:07:50 UTC (rev 15489) @@ -216,6 +216,7 @@ final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); + request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } |
From: <rb...@us...> - 2018-07-19 18:26:22
|
Revision: 15488 http://sourceforge.net/p/htmlunit/code/15488 Author: rbri Date: 2018-07-19 18:26:06 +0000 (Thu, 19 Jul 2018) Log Message: ----------- next step in our endless encoding fight - fix area and image Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java 2018-07-18 19:32:57 UTC (rev 15487) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java 2018-07-19 18:26:06 UTC (rev 15488) @@ -91,6 +91,7 @@ "Not a valid url: " + getHrefAttribute()); } final WebRequest request = new WebRequest(url); + request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); final WebWindow webWindow = enclosingPage.getEnclosingWindow(); webClient.getPage( Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2018-07-18 19:32:57 UTC (rev 15487) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2018-07-19 18:26:06 UTC (rev 15488) @@ -463,6 +463,7 @@ final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); + request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 19:32:57 UTC (rev 15487) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-19 18:26:06 UTC (rev 15488) @@ -103,17 +103,18 @@ } else { requests_.add(requestString); - try (OutputStream out = socket.getOutputStream()) { - if (first || otherResponse_ == null) { - response = firstResponse_; - } - else { - response = otherResponse_; - } - first = false; - out.write(response.getBytes(charset_)); + if (first || otherResponse_ == null) { + response = firstResponse_; } + else { + response = otherResponse_; + } + first = false; } + + try (OutputStream out = socket.getOutputStream()) { + out.write(response.getBytes(charset_)); + } } } catch (final SocketException e) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 19:32:57 UTC (rev 15487) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-19 18:26:06 UTC (rev 15488) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit; +import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF60; import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; import java.net.URL; @@ -26,6 +27,7 @@ import org.openqa.selenium.WebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; /** @@ -221,6 +223,98 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "/area.html?k%C3%B6nig", + IE = "/area.html?k\u00c3\u00b6nig") + @BuggyWebDriver(FF60) + @NotYetImplemented(IE) + public void areaUrlEncodingUTF8Header() throws Exception { + areaUrlEncoding(true, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/area.html?k%C3%B6nig", + IE = "/area.html?k\u00c3\u00b6nig") + @BuggyWebDriver(FF60) + @NotYetImplemented(IE) + public void areaUrlEncodingUTF8Meta() throws Exception { + areaUrlEncoding(false, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/area.html?k%F6nig", + IE = "/area.html?k\u00f6nig") + @BuggyWebDriver(FF60) + @NotYetImplemented(IE) + public void areaUrlEncodingISO8859_1Header() throws Exception { + areaUrlEncoding(true, "ISO-8859-1"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/area.html?k%F6nig", + IE = "/area.html?k\u00f6nig") + @BuggyWebDriver(FF60) + @NotYetImplemented(IE) + public void areaUrlEncodingISO8859_1Meta() throws Exception { + areaUrlEncoding(false, "ISO-8859-1"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.gif?k%C3%B6nig", + IE = "/test.gif?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void imageUrlEncodingUTF8Header() throws Exception { + imageUrlEncoding(true, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.gif?k%C3%B6nig", + IE = "/test.gif?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void imageUrlEncodingUTF8Meta() throws Exception { + imageUrlEncoding(false, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.gif?k%F6nig", + IE = "/test.gif?k\u00f6nig") + @NotYetImplemented(IE) + public void imageUrlEncodingISO8859_1Header() throws Exception { + imageUrlEncoding(true, "ISO_8859_1"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.gif?k%F6nig", + IE = "/test.gif?k\u00f6nig") + @NotYetImplemented(IE) + public void imageUrlEncodingISO8859_1Meta() throws Exception { + imageUrlEncoding(false, "ISO_8859_1"); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = "/test.css?k%C3%B6nig", IE = "/test.css?k\u00c3\u00b6nig") @NotYetImplemented(IE) @@ -301,6 +395,26 @@ true); } + private void areaUrlEncoding(final boolean header, final String charset) throws Exception { + urlEncoding(header, charset, + null, + " <img id='myImg' usemap='#dot' width='100' height='100'" + + " src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAA" + + "HElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='>\n" + + " <map name='dot'>\n" + + " <area id='myLink' shape='rect' coords='0,0,42,42' href='area.html?k\u00F6nig'/>\n" + + " <map>\n", + true); + } + + private void imageUrlEncoding(final boolean header, final String charset) throws Exception { + urlEncoding(header, charset, + null, + " <img id='myImg' src='test.gif?k\u00F6nig'>" + + " <button id='myLink' onClick='document.getElementById(\"myImg\").width'></button>", + true); + } + private void linkUrlEncoding(final boolean header, final String charset) throws Exception { urlEncoding(header, charset, " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>", @@ -418,11 +532,8 @@ } // HtmlApplet.java -// HtmlArea.java // HtmlEmbed.java // HtmlForm.java -// HtmlImage.java // HtmlImageInput.java // HtmlObject.java - } |
From: <rb...@us...> - 2018-07-18 19:33:02
|
Revision: 15487 http://sourceforge.net/p/htmlunit/code/15487 Author: rbri Date: 2018-07-18 19:32:57 +0000 (Wed, 18 Jul 2018) Log Message: ----------- next step in our endless encoding fight - fix iframe and frameset url encoding Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2018-07-18 07:39:43 UTC (rev 15486) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2018-07-18 19:32:57 UTC (rev 15487) @@ -179,6 +179,7 @@ } try { final WebRequest request = new WebRequest(url); + request.setCharset(getPage().getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, getPage().getUrl().toExternalForm()); getPage().getEnclosingWindow().getWebClient().getPage(enclosedWindow_, request); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 07:39:43 UTC (rev 15486) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 19:32:57 UTC (rev 15487) @@ -97,7 +97,9 @@ final String response; if (requestString.contains("/favicon.ico")) { response = "HTTP/1.1 404 Not Found\r\n" - + "Content-Length: 0\r\n\r\n"; + + "Content-Length: 0\r\n" + + "Connection: close\r\n" + + "\r\n"; } else { requests_.add(requestString); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:39:43 UTC (rev 15486) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 19:32:57 UTC (rev 15487) @@ -18,7 +18,6 @@ import java.net.URL; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import org.junit.After; import org.junit.Test; @@ -164,104 +163,58 @@ IE = "/test.html?k\u00c3\u00b6nig") @NotYetImplemented(IE) public void anchorUrlEncodingUTF8Header() throws Exception { - urlEncoding(true, "UTF-8"); + anchorUrlEncoding(true, "UTF-8"); } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.html?k%C3%B6nig", -// IE = "/test.html?k\u00c3\u00b6nig") -// @NotYetImplemented(IE) -// public void anchorUrlEncodingUTF8Meta() throws Exception { -// urlEncoding(false, "UTF-8"); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.html?k%F6nig", -// IE = "/test.html?k\u00f6nig") -// @NotYetImplemented(IE) -// public void anchorUrlEncodingISO8859_1Header() throws Exception { -// urlEncoding(true, "ISO-8859-1"); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.html?k%F6nig", -// IE = "/test.html?k\u00f6nig") -// @NotYetImplemented(IE) -// public void anchorUrlEncodingISO8859_1Meta() throws Exception { -// urlEncoding(false, "ISO-8859-1"); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts("/test.html?k?nig") -// public void anchorUrlEncodingWindows_1251Header() throws Exception { -// urlEncoding(true, "Windows-1251"); -// } -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts("/test.html?k?nig") -// public void anchorUrlEncodingWindows_1251Meta() throws Exception { -// urlEncoding(false, "Windows-1251"); -// } - private void urlEncoding(final boolean header, final String charset) throws Exception { - String html = "<html>\n" - + "<head><title>foo</title>\n"; - if (!header) { - html += " <meta http-equiv='Content-Type' content='text/html; charset=" + charset + "'>\n"; - } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingUTF8Meta() throws Exception { + anchorUrlEncoding(false, "UTF-8"); + } - html += "</head>\n" - + "<body>\n" - + " <a id='myLink' href='test.html?k\u00F6nig'>Click me</a>\n" - + "</body></html>"; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingISO8859_1Header() throws Exception { + anchorUrlEncoding(true, "ISO-8859-1"); + } - String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html"; - if (header) { - firstResponse += "; charset=" + charset; - } - firstResponse += "\r\n" - + "Connection: close\r\n" - + "\r\n" + html; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingISO8859_1Meta() throws Exception { + anchorUrlEncoding(false, "ISO-8859-1"); + } - final String html2 = "<html><head></head><body>" - + "</body></html>"; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("/test.html?k?nig") + public void anchorUrlEncodingWindows_1251Header() throws Exception { + anchorUrlEncoding(true, "Windows-1251"); + } - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html2.length() + "\r\n" - + "Content-Type: text/html; charset=" + charset + "\r\n" - + "Connection: close\r\n" - + "\r\n" - + html2; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(Charset.forName(charset)); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - driver.findElement(By.id("myLink")).click(); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("/test.html?k?nig") + public void anchorUrlEncodingWindows_1251Meta() throws Exception { + anchorUrlEncoding(false, "Windows-1251"); } /** @@ -272,41 +225,7 @@ IE = "/test.css?k\u00c3\u00b6nig") @NotYetImplemented(IE) public void linkUrlEncodingUTF8Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=UTF-8\r\n" - + "Connection: close\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "Connection: close\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); + linkUrlEncoding(true, "UTF-8"); } /** @@ -317,42 +236,51 @@ IE = "/test.css?k\u00c3\u00b6nig") @NotYetImplemented(IE) public void linkUrlEncodingUTF8Meta() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; + linkUrlEncoding(false, "UTF-8"); + } - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "Connection: close\r\n" - + "\r\n" - + html; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingISO8859_1Header() throws Exception { + linkUrlEncoding(true, "ISO_8859_1"); + } - final String css = "p { color: red; }"; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingISO8859_1Meta() throws Exception { + linkUrlEncoding(false, "ISO_8859_1"); + } - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "Connection: close\r\n" - + "\r\n" - + css; + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void iframeUrlEncodingUTF8Header() throws Exception { + iframeUrlEncoding(true, "UTF-8"); + } - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void iframeUrlEncodingUTF8Meta() throws Exception { + iframeUrlEncoding(false, "UTF-8"); } /** @@ -359,40 +287,77 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" + public void iframeUrlEncodingISO8859_1Header() throws Exception { + framesetUrlEncoding("ISO_8859_1"); + } + + private void anchorUrlEncoding(final boolean header, final String charset) throws Exception { + urlEncoding(header, charset, + null, + " <a id='myLink' href='test.html?k\u00F6nig'>Click me</a>", + true); + } + + private void linkUrlEncoding(final boolean header, final String charset) throws Exception { + urlEncoding(header, charset, + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>", + "", + false); + } + + private void iframeUrlEncoding(final boolean header, final String charset) throws Exception { + urlEncoding(header, charset, + " <iframe src='test.html?k\u00F6nig'></iframe> ", + "", + false); + } + + private void urlEncoding(final boolean header, final String charset, + final String addHeader, + final String addHtml, + final boolean click) throws Exception { + String html = "<html>\n" + + "<head><title>foo</title>\n"; + if (!header) { + html += " <meta http-equiv='Content-Type' content='text/html; charset=" + charset + "'>\n"; + } + if (addHeader != null) { + html += addHeader + "\n"; + } + + html += "</head>\n" + "<body>\n" + + addHtml + "\n" + "</body></html>"; - final String firstResponse = "HTTP/1.1 200 OK\r\n" + String firstResponse = "HTTP/1.1 200 OK\r\n" + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=ISO-8859-1\r\n" + + "Content-Type: text/html"; + if (header) { + firstResponse += "; charset=" + charset; + } + firstResponse += "\r\n" + "Connection: close\r\n" - + "\r\n" - + html; + + "\r\n" + html; - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" + final String secondResponse = "HTTP/1.1 404 Not Found\r\n" + + "Content-Length: 0\r\n" + "Connection: close\r\n" - + "\r\n" - + css; + + "\r\n"; primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); + primitiveWebServer_.setCharset(Charset.forName(charset)); primitiveWebServer_.start(); final WebDriver driver = getWebDriver(); driver.get(URL_FIRST.toString()); + if (click) { + driver.findElement(By.id("myLink")).click(); + } String reqUrl = primitiveWebServer_.getRequests().get(1); reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); @@ -404,36 +369,42 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Meta() throws Exception { + public void framesetUrlEncodingUTF8() throws Exception { + framesetUrlEncoding("UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") + @NotYetImplemented(IE) + public void framesetUrlEncodingISO8859_1() throws Exception { + framesetUrlEncoding("ISO_8859_1"); + } + + private void framesetUrlEncoding(final String charset) throws Exception { final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; + + "<frameset><frame src='test.html?k\u00F6nig'></frameset>\n" + + "</html>"; final String firstResponse = "HTTP/1.1 200 OK\r\n" + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" + + "Content-Type: text/html; charset=" + charset + "\r\n" + "Connection: close\r\n" - + "\r\n" - + html; + + "\r\n" + html; - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" + final String secondResponse = "HTTP/1.1 404 Not Found\r\n" + + "Content-Length: 0\r\n" + "Connection: close\r\n" - + "\r\n" - + css; + + "\r\n"; primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); + primitiveWebServer_.setCharset(Charset.forName(charset)); primitiveWebServer_.start(); final WebDriver driver = getWebDriver(); @@ -446,7 +417,6 @@ assertEquals(getExpectedAlerts()[0], reqUrl); } -// BaseFrameElement.java (2 matches) // HtmlApplet.java // HtmlArea.java // HtmlEmbed.java @@ -454,4 +424,5 @@ // HtmlImage.java // HtmlImageInput.java // HtmlObject.java + } |
From: <rb...@us...> - 2018-07-18 07:39:47
|
Revision: 15486 http://sourceforge.net/p/htmlunit/code/15486 Author: rbri Date: 2018-07-18 07:39:43 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:32:41 UTC (rev 15485) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:39:43 UTC (rev 15486) @@ -189,9 +189,7 @@ HttpResponse httpResponse = null; try { -System.out.println("#"); httpResponse = builder.build().execute(hostConfiguration, httpMethod, httpContext); -System.out.println("# done"); } catch (final SSLPeerUnverifiedException s) { // Try to use only SSLv3 instead @@ -204,7 +202,6 @@ } } catch (final Error e) { -System.out.println("##" + e); // in case a StackOverflowError occurs while the connection is leased, it won't get released. // Calling code may catch the StackOverflowError, but due to the leak, the httpClient_ may // come out of connections and throw a ConnectionPoolTimeoutException. @@ -212,10 +209,6 @@ httpClientBuilder_.remove(Thread.currentThread()); throw e; } - catch (final Throwable e) { -System.out.println("###" + e); - throw e; - } final DownloadedContent downloadedBody = downloadResponseBody(httpResponse); final long endTime = System.currentTimeMillis(); @@ -389,7 +382,6 @@ httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); httpContext.removeAttribute(HttpClientContext.CREDS_PROVIDER); httpContext.removeAttribute(HttpClientContext.TARGET_AUTH_STATE); -System.out.println("conn: " + httpMethod.getURI()); return httpMethod; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-18 07:32:41 UTC (rev 15485) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-18 07:39:43 UTC (rev 15486) @@ -1344,7 +1344,6 @@ url = UrlUtils.encodeUrl(url, getBrowserVersion().hasFeature(URL_MINIMAL_QUERY_ENCODING), webRequest.getCharset()); webRequest.setUrl(url); -System.out.println("client: " + url); if (LOG.isDebugEnabled()) { LOG.debug("Load response for " + method + " " + url.toExternalForm()); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 07:32:41 UTC (rev 15485) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 07:39:43 UTC (rev 15486) @@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import java.util.Locale; /** * A very simple implementation of a Web Server. @@ -71,9 +70,6 @@ * @throws IOException if an error occurs */ public void start() throws IOException { -System.out.println("start "); -System.out.println(Locale.getDefault()); -System.out.println(System.getProperty("java.version")); server_ = new ServerSocket(port_); new Thread(new Runnable() { @@ -97,7 +93,6 @@ break; } } -System.out.println("req: " + requestString); final String response; if (requestString.contains("/favicon.ico")) { @@ -114,7 +109,6 @@ response = otherResponse_; } first = false; -System.out.println("resp: " + response); out.write(response.getBytes(charset_)); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:32:41 UTC (rev 15485) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:39:43 UTC (rev 15486) @@ -51,111 +51,112 @@ shutDownAll(); } -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", -// IE = "/test.html?a=b%20c&d=\u00E9\u00E8") -// @NotYetImplemented(IE) -// public void loadPage_EncodeRequest() throws Exception { -// // with query string not encoded -// testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") -// public void loadPage_EncodeRequest2() throws Exception { -// // with query string already encoded -// testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts("/test.html?a=b%20c&d=e%20f") -// public void loadPage_EncodeRequest3() throws Exception { -// // with query string partially encoded -// testRequestUrlEncoding("test.html?a=b%20c&d=e f"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts("/test.html?a=b%20c") -// public void loadPage_EncodeRequest4() throws Exception { -// // with anchor -// testRequestUrlEncoding("test.html?a=b c#myAnchor"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts("/test.html?a=%26%3D%20%2C%24") -// public void loadPage_EncodeRequest5() throws Exception { -// // with query string containing encoded "&", "=", "+", ",", and "$" -// testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts("/page%201.html") -// public void loadPage_EncodeRequest6() throws Exception { -// // with character to encode in path -// testRequestUrlEncoding("page 1.html"); -// } -// -// /** -// * Test that the path and query string are encoded to be valid. -// * @throws Exception if something goes wrong -// */ -// @Test -// @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", -// IE = "/test.html?param=\u00A9\u00A3") -// @NotYetImplemented(IE) -// public void loadPage_EncodeRequest7() throws Exception { -// // unicode -// testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); -// } -// -// private void testRequestUrlEncoding(final String url) throws Exception { -// final String html = "<html>" -// + "<head><title>foo</title></head>" -// + "<body></body></html>"; -// -// final String response = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + html.length() + "\r\n" -// + "Content-Type: text/html\r\n" -// + "\r\n" -// + html; -// -// primitiveWebServer_ = new PrimitiveWebServer(PORT, response); -// primitiveWebServer_.start(); -// -// final WebDriver driver = getWebDriver(); -// -// driver.get(new URL(URL_FIRST, url).toString()); -// String reqUrl = primitiveWebServer_.getRequests().get(0); -// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); -// -// assertEquals(getExpectedAlerts()[0], reqUrl); -// } + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", + IE = "/test.html?a=b%20c&d=\u00E9\u00E8") + @NotYetImplemented(IE) + public void loadPage_EncodeRequest() throws Exception { + // with query string not encoded + testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); + } /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") + public void loadPage_EncodeRequest2() throws Exception { + // with query string already encoded + testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); + } + + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts("/test.html?a=b%20c&d=e%20f") + public void loadPage_EncodeRequest3() throws Exception { + // with query string partially encoded + testRequestUrlEncoding("test.html?a=b%20c&d=e f"); + } + + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts("/test.html?a=b%20c") + public void loadPage_EncodeRequest4() throws Exception { + // with anchor + testRequestUrlEncoding("test.html?a=b c#myAnchor"); + } + + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts("/test.html?a=%26%3D%20%2C%24") + public void loadPage_EncodeRequest5() throws Exception { + // with query string containing encoded "&", "=", "+", ",", and "$" + testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); + } + + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts("/page%201.html") + public void loadPage_EncodeRequest6() throws Exception { + // with character to encode in path + testRequestUrlEncoding("page 1.html"); + } + + /** + * Test that the path and query string are encoded to be valid. + * @throws Exception if something goes wrong + */ + @Test + @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", + IE = "/test.html?param=\u00A9\u00A3") + @NotYetImplemented(IE) + public void loadPage_EncodeRequest7() throws Exception { + // unicode + testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); + } + + private void testRequestUrlEncoding(final String url) throws Exception { + final String html = "<html>" + + "<head><title>foo</title></head>" + + "<body></body></html>"; + + final String response = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html\r\n" + + "Connection: close\r\n" + + "\r\n" + + html; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, response); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(new URL(URL_FIRST, url).toString()); + String reqUrl = primitiveWebServer_.getRequests().get(0); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** * @throws Exception if the test fails */ @Test @@ -263,180 +264,188 @@ assertEquals(getExpectedAlerts()[0], reqUrl); } -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", -// IE = "/test.css?k\u00c3\u00b6nig") -// @NotYetImplemented(IE) -// public void linkUrlEncodingUTF8Header() throws Exception { -// final String html = "<html>\n" -// + "<head><title>foo</title>\n" -// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" -// + "</head>\n" -// + "<body>\n" -// + "</body></html>"; -// -// final String firstResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + html.length() + "\r\n" -// + "Content-Type: text/html; charset=UTF-8\r\n" -// + "\r\n" -// + html; -// -// final String css = "p { color: red; }"; -// -// final String secondResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + css.length() + "\r\n" -// + "Content-Type: text/css\r\n" -// + "\r\n" -// + css; -// -// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); -// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); -// primitiveWebServer_.start(); -// -// final WebDriver driver = getWebDriver(); -// -// driver.get(URL_FIRST.toString()); -// -// String reqUrl = primitiveWebServer_.getRequests().get(1); -// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); -// -// assertEquals(getExpectedAlerts()[0], reqUrl); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", -// IE = "/test.css?k\u00c3\u00b6nig") -// @NotYetImplemented(IE) -// public void linkUrlEncodingUTF8Meta() throws Exception { -// final String html = "<html>\n" -// + "<head><title>foo</title>\n" -// + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" -// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" -// + "</head>\n" -// + "<body>\n" -// + "</body></html>"; -// -// final String firstResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + html.length() + "\r\n" -// + "Content-Type: text/html\r\n" -// + "\r\n" -// + html; -// -// final String css = "p { color: red; }"; -// -// final String secondResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + css.length() + "\r\n" -// + "Content-Type: text/css\r\n" -// + "\r\n" -// + css; -// -// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); -// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); -// primitiveWebServer_.start(); -// -// final WebDriver driver = getWebDriver(); -// -// driver.get(URL_FIRST.toString()); -// -// String reqUrl = primitiveWebServer_.getRequests().get(1); -// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); -// -// assertEquals(getExpectedAlerts()[0], reqUrl); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.css?k%F6nig", -// IE = "/test.css?k\u00f6nig") -// @NotYetImplemented(IE) -// public void linkUrlEncodingISO8859_1Header() throws Exception { -// final String html = "<html>\n" -// + "<head><title>foo</title>\n" -// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" -// + "</head>\n" -// + "<body>\n" -// + "</body></html>"; -// -// final String firstResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + html.length() + "\r\n" -// + "Content-Type: text/html; charset=ISO-8859-1\r\n" -// + "\r\n" -// + html; -// -// final String css = "p { color: red; }"; -// -// final String secondResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + css.length() + "\r\n" -// + "Content-Type: text/css\r\n" -// + "\r\n" -// + css; -// -// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); -// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); -// primitiveWebServer_.start(); -// -// final WebDriver driver = getWebDriver(); -// -// driver.get(URL_FIRST.toString()); -// -// String reqUrl = primitiveWebServer_.getRequests().get(1); -// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); -// -// assertEquals(getExpectedAlerts()[0], reqUrl); -// } -// -// /** -// * @throws Exception if the test fails -// */ -// @Test -// @Alerts(DEFAULT = "/test.css?k%F6nig", -// IE = "/test.css?k\u00f6nig") -// @NotYetImplemented(IE) -// public void linkUrlEncodingISO8859_1Meta() throws Exception { -// final String html = "<html>\n" -// + "<head><title>foo</title>\n" -// + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" -// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" -// + "</head>\n" -// + "<body>\n" -// + "</body></html>"; -// -// final String firstResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + html.length() + "\r\n" -// + "Content-Type: text/html\r\n" -// + "\r\n" -// + html; -// -// final String css = "p { color: red; }"; -// -// final String secondResponse = "HTTP/1.1 200 OK\r\n" -// + "Content-Length: " + css.length() + "\r\n" -// + "Content-Type: text/css\r\n" -// + "\r\n" -// + css; -// -// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); -// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); -// primitiveWebServer_.start(); -// -// final WebDriver driver = getWebDriver(); -// -// driver.get(URL_FIRST.toString()); -// -// String reqUrl = primitiveWebServer_.getRequests().get(1); -// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); -// -// assertEquals(getExpectedAlerts()[0], reqUrl); -// } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%C3%B6nig", + IE = "/test.css?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingUTF8Header() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n" + + "Connection: close\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "Connection: close\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.UTF_8); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%C3%B6nig", + IE = "/test.css?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingUTF8Meta() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html\r\n" + + "Connection: close\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "Connection: close\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.UTF_8); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingISO8859_1Header() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html; charset=ISO-8859-1\r\n" + + "Connection: close\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "Connection: close\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingISO8859_1Meta() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html\r\n" + + "Connection: close\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "Connection: close\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + // BaseFrameElement.java (2 matches) // HtmlApplet.java // HtmlArea.java |
From: <rb...@us...> - 2018-07-18 07:32:44
|
Revision: 15485 http://sourceforge.net/p/htmlunit/code/15485 Author: rbri Date: 2018-07-18 07:32:41 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:26:45 UTC (rev 15484) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:32:41 UTC (rev 15485) @@ -234,7 +234,9 @@ if (header) { firstResponse += "; charset=" + charset; } - firstResponse += "\r\n\r\n" + html; + firstResponse += "\r\n" + + "Connection: close\r\n" + + "\r\n" + html; final String html2 = "<html><head></head><body>" + "</body></html>"; @@ -242,6 +244,7 @@ final String secondResponse = "HTTP/1.1 200 OK\r\n" + "Content-Length: " + html2.length() + "\r\n" + "Content-Type: text/html; charset=" + charset + "\r\n" + + "Connection: close\r\n" + "\r\n" + html2; |
From: <rb...@us...> - 2018-07-18 07:26:49
|
Revision: 15484 http://sourceforge.net/p/htmlunit/code/15484 Author: rbri Date: 2018-07-18 07:26:45 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:23:18 UTC (rev 15483) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:26:45 UTC (rev 15484) @@ -204,7 +204,7 @@ } } catch (final Error e) { -System.out.println("#" + e); +System.out.println("##" + e); // in case a StackOverflowError occurs while the connection is leased, it won't get released. // Calling code may catch the StackOverflowError, but due to the leak, the httpClient_ may // come out of connections and throw a ConnectionPoolTimeoutException. @@ -213,7 +213,7 @@ throw e; } catch (final Throwable e) { -e.printStackTrace(); +System.out.println("###" + e); throw e; } |
From: <rb...@us...> - 2018-07-18 07:23:21
|
Revision: 15483 http://sourceforge.net/p/htmlunit/code/15483 Author: rbri Date: 2018-07-18 07:23:18 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:19:23 UTC (rev 15482) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:23:18 UTC (rev 15483) @@ -212,6 +212,10 @@ httpClientBuilder_.remove(Thread.currentThread()); throw e; } + catch (final Throwable e) { +e.printStackTrace(); + throw e; + } final DownloadedContent downloadedBody = downloadResponseBody(httpResponse); final long endTime = System.currentTimeMillis(); |
From: <rb...@us...> - 2018-07-18 07:19:27
|
Revision: 15482 http://sourceforge.net/p/htmlunit/code/15482 Author: rbri Date: 2018-07-18 07:19:23 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:14:15 UTC (rev 15481) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:19:23 UTC (rev 15482) @@ -189,7 +189,9 @@ HttpResponse httpResponse = null; try { +System.out.println("#"); httpResponse = builder.build().execute(hostConfiguration, httpMethod, httpContext); +System.out.println("# done"); } catch (final SSLPeerUnverifiedException s) { // Try to use only SSLv3 instead @@ -202,6 +204,7 @@ } } catch (final Error e) { +System.out.println("#" + e); // in case a StackOverflowError occurs while the connection is leased, it won't get released. // Calling code may catch the StackOverflowError, but due to the leak, the httpClient_ may // come out of connections and throw a ConnectionPoolTimeoutException. |
From: <rb...@us...> - 2018-07-18 07:14:24
|
Revision: 15481 http://sourceforge.net/p/htmlunit/code/15481 Author: rbri Date: 2018-07-18 07:14:15 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:05:05 UTC (rev 15480) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 07:14:15 UTC (rev 15481) @@ -382,7 +382,7 @@ httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); httpContext.removeAttribute(HttpClientContext.CREDS_PROVIDER); httpContext.removeAttribute(HttpClientContext.TARGET_AUTH_STATE); - +System.out.println("conn: " + httpMethod.getURI()); return httpMethod; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-18 07:05:05 UTC (rev 15480) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-18 07:14:15 UTC (rev 15481) @@ -1344,6 +1344,7 @@ url = UrlUtils.encodeUrl(url, getBrowserVersion().hasFeature(URL_MINIMAL_QUERY_ENCODING), webRequest.getCharset()); webRequest.setUrl(url); +System.out.println("client: " + url); if (LOG.isDebugEnabled()) { LOG.debug("Load response for " + method + " " + url.toExternalForm()); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:05:05 UTC (rev 15480) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 07:14:15 UTC (rev 15481) @@ -225,7 +225,7 @@ html += "</head>\n" + "<body>\n" - + " <a id='myLink' href='test.html?ku00F6nig'>Click me</a>\n" + + " <a id='myLink' href='test.html?k\u00F6nig'>Click me</a>\n" + "</body></html>"; String firstResponse = "HTTP/1.1 200 OK\r\n" |
From: <rb...@us...> - 2018-07-18 07:05:09
|
Revision: 15480 http://sourceforge.net/p/htmlunit/code/15480 Author: rbri Date: 2018-07-18 07:05:05 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:47:06 UTC (rev 15479) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 07:05:05 UTC (rev 15480) @@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * A very simple implementation of a Web Server. @@ -71,6 +72,8 @@ */ public void start() throws IOException { System.out.println("start "); +System.out.println(Locale.getDefault()); +System.out.println(System.getProperty("java.version")); server_ = new ServerSocket(port_); new Thread(new Runnable() { |
From: <rb...@us...> - 2018-07-18 06:47:09
|
Revision: 15479 http://sourceforge.net/p/htmlunit/code/15479 Author: rbri Date: 2018-07-18 06:47:06 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:39:42 UTC (rev 15478) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:47:06 UTC (rev 15479) @@ -225,7 +225,7 @@ html += "</head>\n" + "<body>\n" - + " <a id='myLink' href='test.html?k\u00F6nig'>Click me</a>\n" + + " <a id='myLink' href='test.html?ku00F6nig'>Click me</a>\n" + "</body></html>"; String firstResponse = "HTTP/1.1 200 OK\r\n" |
From: <rb...@us...> - 2018-07-18 06:39:48
|
Revision: 15478 http://sourceforge.net/p/htmlunit/code/15478 Author: rbri Date: 2018-07-18 06:39:42 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:33:19 UTC (rev 15477) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:39:42 UTC (rev 15478) @@ -94,6 +94,7 @@ break; } } +System.out.println("req: " + requestString); final String response; if (requestString.contains("/favicon.ico")) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:33:19 UTC (rev 15477) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-18 06:39:42 UTC (rev 15478) @@ -51,111 +51,111 @@ shutDownAll(); } - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", - IE = "/test.html?a=b%20c&d=\u00E9\u00E8") - @NotYetImplemented(IE) - public void loadPage_EncodeRequest() throws Exception { - // with query string not encoded - testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); - } +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?a=b%20c&d=%C3%A9%C3%A8", +// IE = "/test.html?a=b%20c&d=\u00E9\u00E8") +// @NotYetImplemented(IE) +// public void loadPage_EncodeRequest() throws Exception { +// // with query string not encoded +// testRequestUrlEncoding("test.html?a=b c&d=\u00E9\u00E8"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") +// public void loadPage_EncodeRequest2() throws Exception { +// // with query string already encoded +// testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c&d=e%20f") +// public void loadPage_EncodeRequest3() throws Exception { +// // with query string partially encoded +// testRequestUrlEncoding("test.html?a=b%20c&d=e f"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=b%20c") +// public void loadPage_EncodeRequest4() throws Exception { +// // with anchor +// testRequestUrlEncoding("test.html?a=b c#myAnchor"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/test.html?a=%26%3D%20%2C%24") +// public void loadPage_EncodeRequest5() throws Exception { +// // with query string containing encoded "&", "=", "+", ",", and "$" +// testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts("/page%201.html") +// public void loadPage_EncodeRequest6() throws Exception { +// // with character to encode in path +// testRequestUrlEncoding("page 1.html"); +// } +// +// /** +// * Test that the path and query string are encoded to be valid. +// * @throws Exception if something goes wrong +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", +// IE = "/test.html?param=\u00A9\u00A3") +// @NotYetImplemented(IE) +// public void loadPage_EncodeRequest7() throws Exception { +// // unicode +// testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); +// } +// +// private void testRequestUrlEncoding(final String url) throws Exception { +// final String html = "<html>" +// + "<head><title>foo</title></head>" +// + "<body></body></html>"; +// +// final String response = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, response); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(new URL(URL_FIRST, url).toString()); +// String reqUrl = primitiveWebServer_.getRequests().get(0); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c&d=%C3%A9%C3%A8") - public void loadPage_EncodeRequest2() throws Exception { - // with query string already encoded - testRequestUrlEncoding("test.html?a=b%20c&d=%C3%A9%C3%A8"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c&d=e%20f") - public void loadPage_EncodeRequest3() throws Exception { - // with query string partially encoded - testRequestUrlEncoding("test.html?a=b%20c&d=e f"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=b%20c") - public void loadPage_EncodeRequest4() throws Exception { - // with anchor - testRequestUrlEncoding("test.html?a=b c#myAnchor"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/test.html?a=%26%3D%20%2C%24") - public void loadPage_EncodeRequest5() throws Exception { - // with query string containing encoded "&", "=", "+", ",", and "$" - testRequestUrlEncoding("test.html?a=%26%3D%20%2C%24"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts("/page%201.html") - public void loadPage_EncodeRequest6() throws Exception { - // with character to encode in path - testRequestUrlEncoding("page 1.html"); - } - - /** - * Test that the path and query string are encoded to be valid. - * @throws Exception if something goes wrong - */ - @Test - @Alerts(DEFAULT = "/test.html?param=%C2%A9%C2%A3", - IE = "/test.html?param=\u00A9\u00A3") - @NotYetImplemented(IE) - public void loadPage_EncodeRequest7() throws Exception { - // unicode - testRequestUrlEncoding("test.html?param=\u00A9\u00A3"); - } - - private void testRequestUrlEncoding(final String url) throws Exception { - final String html = "<html>" - + "<head><title>foo</title></head>" - + "<body></body></html>"; - - final String response = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, response); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(new URL(URL_FIRST, url).toString()); - String reqUrl = primitiveWebServer_.getRequests().get(0); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** * @throws Exception if the test fails */ @Test @@ -165,57 +165,57 @@ public void anchorUrlEncodingUTF8Header() throws Exception { urlEncoding(true, "UTF-8"); } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%C3%B6nig", +// IE = "/test.html?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingUTF8Meta() throws Exception { +// urlEncoding(false, "UTF-8"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%F6nig", +// IE = "/test.html?k\u00f6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingISO8859_1Header() throws Exception { +// urlEncoding(true, "ISO-8859-1"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.html?k%F6nig", +// IE = "/test.html?k\u00f6nig") +// @NotYetImplemented(IE) +// public void anchorUrlEncodingISO8859_1Meta() throws Exception { +// urlEncoding(false, "ISO-8859-1"); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts("/test.html?k?nig") +// public void anchorUrlEncodingWindows_1251Header() throws Exception { +// urlEncoding(true, "Windows-1251"); +// } +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts("/test.html?k?nig") +// public void anchorUrlEncodingWindows_1251Meta() throws Exception { +// urlEncoding(false, "Windows-1251"); +// } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%C3%B6nig", - IE = "/test.html?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingUTF8Meta() throws Exception { - urlEncoding(false, "UTF-8"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%F6nig", - IE = "/test.html?k\u00f6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingISO8859_1Header() throws Exception { - urlEncoding(true, "ISO-8859-1"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.html?k%F6nig", - IE = "/test.html?k\u00f6nig") - @NotYetImplemented(IE) - public void anchorUrlEncodingISO8859_1Meta() throws Exception { - urlEncoding(false, "ISO-8859-1"); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts("/test.html?k?nig") - public void anchorUrlEncodingWindows_1251Header() throws Exception { - urlEncoding(true, "Windows-1251"); - } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts("/test.html?k?nig") - public void anchorUrlEncodingWindows_1251Meta() throws Exception { - urlEncoding(false, "Windows-1251"); - } - private void urlEncoding(final boolean header, final String charset) throws Exception { String html = "<html>\n" + "<head><title>foo</title>\n"; @@ -260,180 +260,180 @@ assertEquals(getExpectedAlerts()[0], reqUrl); } - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%C3%B6nig", - IE = "/test.css?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingUTF8Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", +// IE = "/test.css?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingUTF8Header() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html; charset=UTF-8\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%C3%B6nig", +// IE = "/test.css?k\u00c3\u00b6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingUTF8Meta() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.UTF_8); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%F6nig", +// IE = "/test.css?k\u00f6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingISO8859_1Header() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html; charset=ISO-8859-1\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } +// +// /** +// * @throws Exception if the test fails +// */ +// @Test +// @Alerts(DEFAULT = "/test.css?k%F6nig", +// IE = "/test.css?k\u00f6nig") +// @NotYetImplemented(IE) +// public void linkUrlEncodingISO8859_1Meta() throws Exception { +// final String html = "<html>\n" +// + "<head><title>foo</title>\n" +// + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" +// + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" +// + "</head>\n" +// + "<body>\n" +// + "</body></html>"; +// +// final String firstResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + html.length() + "\r\n" +// + "Content-Type: text/html\r\n" +// + "\r\n" +// + html; +// +// final String css = "p { color: red; }"; +// +// final String secondResponse = "HTTP/1.1 200 OK\r\n" +// + "Content-Length: " + css.length() + "\r\n" +// + "Content-Type: text/css\r\n" +// + "\r\n" +// + css; +// +// primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); +// primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); +// primitiveWebServer_.start(); +// +// final WebDriver driver = getWebDriver(); +// +// driver.get(URL_FIRST.toString()); +// +// String reqUrl = primitiveWebServer_.getRequests().get(1); +// reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); +// +// assertEquals(getExpectedAlerts()[0], reqUrl); +// } - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=UTF-8\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%C3%B6nig", - IE = "/test.css?k\u00c3\u00b6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingUTF8Meta() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.UTF_8); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Header() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html; charset=ISO-8859-1\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(DEFAULT = "/test.css?k%F6nig", - IE = "/test.css?k\u00f6nig") - @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1Meta() throws Exception { - final String html = "<html>\n" - + "<head><title>foo</title>\n" - + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" - + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" - + "</head>\n" - + "<body>\n" - + "</body></html>"; - - final String firstResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html.length() + "\r\n" - + "Content-Type: text/html\r\n" - + "\r\n" - + html; - - final String css = "p { color: red; }"; - - final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + css.length() + "\r\n" - + "Content-Type: text/css\r\n" - + "\r\n" - + css; - - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); - primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); - primitiveWebServer_.start(); - - final WebDriver driver = getWebDriver(); - - driver.get(URL_FIRST.toString()); - - String reqUrl = primitiveWebServer_.getRequests().get(1); - reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); - - assertEquals(getExpectedAlerts()[0], reqUrl); - } - // BaseFrameElement.java (2 matches) // HtmlApplet.java // HtmlArea.java |
From: <rb...@us...> - 2018-07-18 06:33:22
|
Revision: 15477 http://sourceforge.net/p/htmlunit/code/15477 Author: rbri Date: 2018-07-18 06:33:19 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:21:32 UTC (rev 15476) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:33:19 UTC (rev 15477) @@ -31,6 +31,7 @@ * This covers some cases which are not possible with Jetty. * * @author Ahmed Ashour + * @author Ronald Brill */ public class PrimitiveWebServer { @@ -69,6 +70,7 @@ * @throws IOException if an error occurs */ public void start() throws IOException { +System.out.println("start "); server_ = new ServerSocket(port_); new Thread(new Runnable() { |
From: <rb...@us...> - 2018-07-18 06:21:38
|
Revision: 15476 http://sourceforge.net/p/htmlunit/code/15476 Author: rbri Date: 2018-07-18 06:21:32 +0000 (Wed, 18 Jul 2018) Log Message: ----------- debug at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:15:19 UTC (rev 15475) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-18 06:21:32 UTC (rev 15476) @@ -96,9 +96,7 @@ final String response; if (requestString.contains("/favicon.ico")) { response = "HTTP/1.1 404 Not Found\r\n" - + "Content-Length: 0\r\n" - + "Content-Type: text/html; charset=iso-8859-1\r\n" - + "Connection: Closed\r\n\r\n"; + + "Content-Length: 0\r\n\r\n"; } else { requests_.add(requestString); @@ -110,6 +108,7 @@ response = otherResponse_; } first = false; +System.out.println("resp: " + response); out.write(response.getBytes(charset_)); } } |
From: <rb...@us...> - 2018-07-18 06:15:28
|
Revision: 15475 http://sourceforge.net/p/htmlunit/code/15475 Author: rbri Date: 2018-07-18 06:15:19 +0000 (Wed, 18 Jul 2018) Log Message: ----------- next step in our endless encoding fight - back to the more explicit approach Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-17 19:37:11 UTC (rev 15474) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-18 06:15:19 UTC (rev 15475) @@ -287,20 +287,17 @@ throws URISyntaxException { final HttpContext httpContext = getHttpContext(); - final Charset encCharset = webRequest.getUrlEncodingCharset(); - + final Charset charset = webRequest.getCharset(); // Make sure that the URL is fully encoded. IE actually sends some Unicode chars in request // URLs; because of this we allow some Unicode chars in URLs. However, at this point we're // handing things over the HttpClient, and HttpClient will blow up if we leave these Unicode // chars in the URL. - final URL url = UrlUtils.encodeUrl(webRequest.getUrl(), false, encCharset); + final URL url = UrlUtils.encodeUrl(webRequest.getUrl(), false, charset); URI uri = UrlUtils.toURI(url, escapeQuery(url.getQuery())); if (getVirtualHost() != null) { uri = URI.create(getVirtualHost()); } - - final Charset charset = webRequest.getCharset(); final HttpRequestBase httpMethod = buildHttpMethod(webRequest.getHttpMethod(), uri); setProxy(httpMethod, webRequest); @@ -309,7 +306,7 @@ if (!webRequest.getRequestParameters().isEmpty()) { final List<NameValuePair> pairs = webRequest.getRequestParameters(); final org.apache.http.NameValuePair[] httpClientPairs = NameValuePair.toHttpClient(pairs); - final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), encCharset); + final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), charset); uri = UrlUtils.toURI(url, query); httpMethod.setURI(uri); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-17 19:37:11 UTC (rev 15474) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-18 06:15:19 UTC (rev 15475) @@ -36,6 +36,7 @@ import java.net.URLConnection; import java.net.URLDecoder; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; @@ -461,6 +462,8 @@ @SuppressWarnings("unchecked") public <P extends Page> P getPage(final URL url) throws IOException, FailingHttpStatusCodeException { final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); + request.setCharset(StandardCharsets.UTF_8); + return (P) getPage(getCurrentWindow().getTopWindow(), request); } @@ -881,6 +884,7 @@ if (url != null) { try { final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); + request.setCharset(StandardCharsets.UTF_8); if (getBrowserVersion().hasFeature(DIALOGWINDOW_REFERER) && openerPage != null) { @@ -1012,6 +1016,7 @@ final HtmlPage openerPage = (HtmlPage) opener.getEnclosedPage(); final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); + request.setCharset(StandardCharsets.UTF_8); if (getBrowserVersion().hasFeature(DIALOGWINDOW_REFERER) && openerPage != null) { final String referer = openerPage.getUrl().toExternalForm(); @@ -1337,7 +1342,7 @@ WebAssert.notNull("parameters", parameters); url = UrlUtils.encodeUrl(url, getBrowserVersion().hasFeature(URL_MINIMAL_QUERY_ENCODING), - webRequest.getUrlEncodingCharset()); + webRequest.getCharset()); webRequest.setUrl(url); if (LOG.isDebugEnabled()) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-17 19:37:11 UTC (rev 15474) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-18 06:15:19 UTC (rev 15475) @@ -23,7 +23,6 @@ import java.net.IDN; import java.net.URL; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -64,7 +63,6 @@ private Credentials urlCredentials_; private Credentials credentials_; private transient Charset charset_ = ISO_8859_1; - private transient Charset urlEncodingCharset_; /* These two are mutually exclusive; additionally, requestBody_ should only be set for POST requests. */ private List<NameValuePair> requestParameters_ = Collections.emptyList(); @@ -432,31 +430,6 @@ } /** - * @param charset the character set to use for url (param) encoding - */ - public void setUrlEncodingCharset(final Charset charset) { - urlEncodingCharset_ = charset; - } - - /** - * @return the character set to use to encode the url (params) - */ - public Charset getUrlEncodingCharset() { - if (urlEncodingCharset_ != null) { - return urlEncodingCharset_; - } - - if (HttpMethod.GET == getHttpMethod() - || HttpMethod.DELETE == getHttpMethod() - || HttpMethod.HEAD == getHttpMethod() - || HttpMethod.OPTIONS == getHttpMethod() - || HttpMethod.TRACE == getHttpMethod()) { - return StandardCharsets.UTF_8; - } - return charset_; - } - - /** * Returns a string representation of this object. * @return a string representation of this object */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2018-07-17 19:37:11 UTC (rev 15474) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2018-07-18 06:15:19 UTC (rev 15475) @@ -169,9 +169,9 @@ } final WebRequest webRequest = new WebRequest(url, browser.getHtmlAcceptHeader()); + // use the page encoding even if this is a GET requests webRequest.setCharset(page.getCharset()); - // use the page encoding even if this is a GET requests - webRequest.setUrlEncodingCharset(page.getCharset()); + webRequest.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); if (LOG.isDebugEnabled()) { LOG.debug( Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2018-07-17 19:37:11 UTC (rev 15474) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2018-07-18 06:15:19 UTC (rev 15475) @@ -228,7 +228,7 @@ final WebRequest request = new WebRequest(url); // use the page encoding even if this is a GET requests - request.setUrlEncodingCharset(page.getCharset()); + request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); |
From: <rb...@us...> - 2018-07-17 19:37:16
|
Revision: 15474 http://sourceforge.net/p/htmlunit/code/15474 Author: rbri Date: 2018-07-17 19:37:11 +0000 (Tue, 17 Jul 2018) Log Message: ----------- desperate try to fix problem only visible at the server Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-17 19:33:14 UTC (rev 15473) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-17 19:37:11 UTC (rev 15474) @@ -241,7 +241,7 @@ final String secondResponse = "HTTP/1.1 200 OK\r\n" + "Content-Length: " + html2.length() + "\r\n" - + "Content-Type: text/html\r\n" + + "Content-Type: text/html; charset=" + charset + "\r\n" + "\r\n" + html2; @@ -433,4 +433,13 @@ assertEquals(getExpectedAlerts()[0], reqUrl); } + +// BaseFrameElement.java (2 matches) +// HtmlApplet.java +// HtmlArea.java +// HtmlEmbed.java +// HtmlForm.java +// HtmlImage.java +// HtmlImageInput.java +// HtmlObject.java } |
From: <rb...@us...> - 2018-07-17 19:33:17
|
Revision: 15473 http://sourceforge.net/p/htmlunit/code/15473 Author: rbri Date: 2018-07-17 19:33:14 +0000 (Tue, 17 Jul 2018) Log Message: ----------- % cleanup Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2018-07-17 19:24:28 UTC (rev 15472) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2018-07-17 19:33:14 UTC (rev 15473) @@ -14,8 +14,6 @@ */ package com.gargoylesoftware.htmlunit; -import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; - import java.net.URLEncoder; import java.util.Arrays; |
From: <rb...@us...> - 2018-07-17 19:24:31
|
Revision: 15472 http://sourceforge.net/p/htmlunit/code/15472 Author: rbri Date: 2018-07-17 19:24:28 +0000 (Tue, 17 Jul 2018) Log Message: ----------- cleanup, selenium has removed some dependencies Modified Paths: -------------- trunk/htmlunit/pom.xml Modified: trunk/htmlunit/pom.xml =================================================================== --- trunk/htmlunit/pom.xml 2018-07-17 18:25:30 UTC (rev 15471) +++ trunk/htmlunit/pom.xml 2018-07-17 19:24:28 UTC (rev 15472) @@ -855,16 +855,6 @@ <version>4.5.6</version> <type>test-jar</type> <scope>test</scope> - <exclusions> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>net.sourceforge.htmlunit</groupId> @@ -976,14 +966,6 @@ <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> </exclusion> - <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - </exclusion> </exclusions> </dependency> <dependency> @@ -997,10 +979,6 @@ <artifactId>httpclient</artifactId> </exclusion> <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </exclusion> @@ -1021,10 +999,6 @@ <artifactId>httpclient</artifactId> </exclusion> <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </exclusion> @@ -1041,10 +1015,6 @@ <artifactId>httpclient</artifactId> </exclusion> <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </exclusion> @@ -1061,10 +1031,6 @@ <artifactId>httpclient</artifactId> </exclusion> <exclusion> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </exclusion> - <exclusion> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </exclusion> |
From: <rb...@us...> - 2018-07-17 18:25:38
|
Revision: 15471 http://sourceforge.net/p/htmlunit/code/15471 Author: rbri Date: 2018-07-17 18:25:30 +0000 (Tue, 17 Jul 2018) Log Message: ----------- next step in our endless encoding fight - more tests are needed Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-16 19:03:46 UTC (rev 15470) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-17 18:25:30 UTC (rev 15471) @@ -64,6 +64,7 @@ private Credentials urlCredentials_; private Credentials credentials_; private transient Charset charset_ = ISO_8859_1; + private transient Charset urlEncodingCharset_; /* These two are mutually exclusive; additionally, requestBody_ should only be set for POST requests. */ private List<NameValuePair> requestParameters_ = Collections.emptyList(); @@ -431,10 +432,20 @@ } /** - * Returns the character set to use to encode the url params. - * @return the character set to use to encode the url params + * @param charset the character set to use for url (param) encoding */ + public void setUrlEncodingCharset(final Charset charset) { + urlEncodingCharset_ = charset; + } + + /** + * @return the character set to use to encode the url (params) + */ public Charset getUrlEncodingCharset() { + if (urlEncodingCharset_ != null) { + return urlEncodingCharset_; + } + if (HttpMethod.GET == getHttpMethod() || HttpMethod.DELETE == getHttpMethod() || HttpMethod.HEAD == getHttpMethod() Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2018-07-16 19:03:46 UTC (rev 15470) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2018-07-17 18:25:30 UTC (rev 15471) @@ -170,6 +170,8 @@ final WebRequest webRequest = new WebRequest(url, browser.getHtmlAcceptHeader()); webRequest.setCharset(page.getCharset()); + // use the page encoding even if this is a GET requests + webRequest.setUrlEncodingCharset(page.getCharset()); webRequest.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); if (LOG.isDebugEnabled()) { LOG.debug( Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2018-07-16 19:03:46 UTC (rev 15470) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java 2018-07-17 18:25:30 UTC (rev 15471) @@ -227,6 +227,8 @@ final URL url = page.getFullyQualifiedUrl(getHrefAttribute()); final WebRequest request = new WebRequest(url); + // use the page encoding even if this is a GET requests + request.setUrlEncodingCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-16 19:03:46 UTC (rev 15470) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-17 18:25:30 UTC (rev 15471) @@ -80,14 +80,18 @@ final Socket socket = server_.accept(); final InputStream in = socket.getInputStream(); final CharArrayWriter writer = new CharArrayWriter(); + + String requestString = writer.toString(); int i; + while ((i = in.read()) != -1) { writer.append((char) i); - if (i == '\n' && writer.toString().endsWith("\r\n\r\n")) { + requestString = writer.toString(); + + if (i == '\n' && requestString.endsWith("\r\n\r\n")) { break; } } - final String requestString = writer.toString(); final String response; if (requestString.contains("/favicon.ico")) { @@ -97,7 +101,7 @@ + "Connection: Closed\r\n\r\n"; } else { - requests_.add(writer.toString()); + requests_.add(requestString); try (OutputStream out = socket.getOutputStream()) { if (first || otherResponse_ == null) { response = firstResponse_; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-16 19:03:46 UTC (rev 15470) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-17 18:25:30 UTC (rev 15471) @@ -17,6 +17,7 @@ import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; import java.net.URL; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.junit.After; @@ -132,12 +133,15 @@ } private void testRequestUrlEncoding(final String url) throws Exception { + final String html = "<html>" + + "<head><title>foo</title></head>" + + "<body></body></html>"; + final String response = "HTTP/1.1 200 OK\r\n" - + "Content-Length: 58\r\n" + + "Content-Length: " + html.length() + "\r\n" + "Content-Type: text/html\r\n" + "\r\n" - + "<html><head><title>foo</title></head><body>" - + "</body></html>"; + + html; primitiveWebServer_ = new PrimitiveWebServer(PORT, response); primitiveWebServer_.start(); @@ -146,9 +150,111 @@ driver.get(new URL(URL_FIRST, url).toString()); String reqUrl = primitiveWebServer_.getRequests().get(0); - if (reqUrl.contains("/favicon.ico")) { - reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingUTF8Header() throws Exception { + urlEncoding(true, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%C3%B6nig", + IE = "/test.html?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingUTF8Meta() throws Exception { + urlEncoding(false, "UTF-8"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingISO8859_1Header() throws Exception { + urlEncoding(true, "ISO-8859-1"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.html?k%F6nig", + IE = "/test.html?k\u00f6nig") + @NotYetImplemented(IE) + public void anchorUrlEncodingISO8859_1Meta() throws Exception { + urlEncoding(false, "ISO-8859-1"); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("/test.html?k?nig") + public void anchorUrlEncodingWindows_1251Header() throws Exception { + urlEncoding(true, "Windows-1251"); + } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("/test.html?k?nig") + public void anchorUrlEncodingWindows_1251Meta() throws Exception { + urlEncoding(false, "Windows-1251"); + } + + private void urlEncoding(final boolean header, final String charset) throws Exception { + String html = "<html>\n" + + "<head><title>foo</title>\n"; + if (!header) { + html += " <meta http-equiv='Content-Type' content='text/html; charset=" + charset + "'>\n"; } + + html += "</head>\n" + + "<body>\n" + + " <a id='myLink' href='test.html?k\u00F6nig'>Click me</a>\n" + + "</body></html>"; + + String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html"; + if (header) { + firstResponse += "; charset=" + charset; + } + firstResponse += "\r\n\r\n" + html; + + final String html2 = "<html><head></head><body>" + + "</body></html>"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html2.length() + "\r\n" + + "Content-Type: text/html\r\n" + + "\r\n" + + html2; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(Charset.forName(charset)); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + driver.findElement(By.id("myLink")).click(); + + String reqUrl = primitiveWebServer_.getRequests().get(1); reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); assertEquals(getExpectedAlerts()[0], reqUrl); @@ -158,16 +264,59 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "/bug.html?k%EF%BF%BDnig", - IE = "/bug.html?k\u00ef\u00bf\u00bdnig") + @Alerts(DEFAULT = "/test.css?k%C3%B6nig", + IE = "/test.css?k\u00c3\u00b6nig") @NotYetImplemented(IE) - public void linkUrlEncodingUTF8() throws Exception { + public void linkUrlEncodingUTF8Header() throws Exception { final String html = "<html>\n" + "<head><title>foo</title>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + + "</body></html>"; + + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.UTF_8); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%C3%B6nig", + IE = "/test.css?k\u00c3\u00b6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingUTF8Meta() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + "</head>\n" + "<body>\n" - + " <a id='myLink' href='bug.html?k\u00F6nig'>Click me</a>\n" + "</body></html>"; final String firstResponse = "HTTP/1.1 200 OK\r\n" @@ -176,14 +325,56 @@ + "\r\n" + html; - final String html2 = "<html><head><title>foo</title></head><body>" + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + + "\r\n" + + css; + + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.UTF_8); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + + driver.get(URL_FIRST.toString()); + + String reqUrl = primitiveWebServer_.getRequests().get(1); + reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); + + assertEquals(getExpectedAlerts()[0], reqUrl); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") + @NotYetImplemented(IE) + public void linkUrlEncodingISO8859_1Header() throws Exception { + final String html = "<html>\n" + + "<head><title>foo</title>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + + "</head>\n" + + "<body>\n" + "</body></html>"; + final String firstResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html.length() + "\r\n" + + "Content-Type: text/html; charset=ISO-8859-1\r\n" + + "\r\n" + + html; + + final String css = "p { color: red; }"; + final String secondResponse = "HTTP/1.1 200 OK\r\n" - + "Content-Length: " + html2.length() + "\r\n" - + "Content-Type: text/html\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + "\r\n" - + html2; + + css; primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); @@ -192,7 +383,6 @@ final WebDriver driver = getWebDriver(); driver.get(URL_FIRST.toString()); - driver.findElement(By.id("myLink")).click(); String reqUrl = primitiveWebServer_.getRequests().get(1); reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); @@ -204,16 +394,16 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "/bug.html?k%F6nig", - IE = "/bug.html?k\u00f6nig") + @Alerts(DEFAULT = "/test.css?k%F6nig", + IE = "/test.css?k\u00f6nig") @NotYetImplemented(IE) - public void linkUrlEncodingISO8859_1() throws Exception { + public void linkUrlEncodingISO8859_1Meta() throws Exception { final String html = "<html>\n" + "<head><title>foo</title>\n" + " <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n" + + " <link rel='stylesheet' type='text/css' href='test.css?k\u00F6nig'>" + "</head>\n" + "<body>\n" - + " <a id='myLink' href='bug.html?k\u00F6nig'>Click me</a>\n" + "</body></html>"; final String firstResponse = "HTTP/1.1 200 OK\r\n" @@ -222,14 +412,15 @@ + "\r\n" + html; - final String response = "HTTP/1.1 200 OK\r\n" - + "Content-Length: 2\r\n" - + "Content-Type: text/html\r\n" + final String css = "p { color: red; }"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + css.length() + "\r\n" + + "Content-Type: text/css\r\n" + "\r\n" - + "<html><head><title>foo</title></head><body>" - + "</body></html>"; + + css; - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, response); + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); primitiveWebServer_.start(); @@ -236,12 +427,8 @@ final WebDriver driver = getWebDriver(); driver.get(URL_FIRST.toString()); - driver.findElement(By.id("myLink")).click(); String reqUrl = primitiveWebServer_.getRequests().get(1); - if (reqUrl.contains("/favicon.ico")) { - reqUrl = primitiveWebServer_.getRequests().get(2); - } reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); assertEquals(getExpectedAlerts()[0], reqUrl); |
From: <rb...@us...> - 2018-07-16 19:03:51
|
Revision: 15470 http://sourceforge.net/p/htmlunit/code/15470 Author: rbri Date: 2018-07-16 19:03:46 +0000 (Mon, 16 Jul 2018) Log Message: ----------- next step in our endless encoding fight Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-16 17:46:31 UTC (rev 15469) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-16 19:03:46 UTC (rev 15470) @@ -28,7 +28,6 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -287,24 +286,14 @@ private HttpUriRequest makeHttpMethod(final WebRequest webRequest, final HttpClientBuilder httpClientBuilder) throws URISyntaxException { - final Charset charset = webRequest.getCharset(); final HttpContext httpContext = getHttpContext(); + final Charset encCharset = webRequest.getUrlEncodingCharset(); // Make sure that the URL is fully encoded. IE actually sends some Unicode chars in request // URLs; because of this we allow some Unicode chars in URLs. However, at this point we're // handing things over the HttpClient, and HttpClient will blow up if we leave these Unicode // chars in the URL. - final URL url; - if (HttpMethod.GET == webRequest.getHttpMethod() - || HttpMethod.DELETE == webRequest.getHttpMethod() - || HttpMethod.HEAD == webRequest.getHttpMethod() - || HttpMethod.OPTIONS == webRequest.getHttpMethod() - || HttpMethod.TRACE == webRequest.getHttpMethod()) { - url = UrlUtils.encodeUrl(webRequest.getUrl(), false, StandardCharsets.UTF_8); - } - else { - url = UrlUtils.encodeUrl(webRequest.getUrl(), false, charset); - } + final URL url = UrlUtils.encodeUrl(webRequest.getUrl(), false, encCharset); URI uri = UrlUtils.toURI(url, escapeQuery(url.getQuery())); if (getVirtualHost() != null) { @@ -311,14 +300,16 @@ uri = URI.create(getVirtualHost()); } + final Charset charset = webRequest.getCharset(); final HttpRequestBase httpMethod = buildHttpMethod(webRequest.getHttpMethod(), uri); setProxy(httpMethod, webRequest); + if (!(httpMethod instanceof HttpEntityEnclosingRequest)) { // this is the case for GET as well as TRACE, DELETE, OPTIONS and HEAD if (!webRequest.getRequestParameters().isEmpty()) { final List<NameValuePair> pairs = webRequest.getRequestParameters(); final org.apache.http.NameValuePair[] httpClientPairs = NameValuePair.toHttpClient(pairs); - final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), charset); + final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), encCharset); uri = UrlUtils.toURI(url, query); httpMethod.setURI(uri); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-16 17:46:31 UTC (rev 15469) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-16 19:03:46 UTC (rev 15470) @@ -1337,7 +1337,7 @@ WebAssert.notNull("parameters", parameters); url = UrlUtils.encodeUrl(url, getBrowserVersion().hasFeature(URL_MINIMAL_QUERY_ENCODING), - webRequest.getCharset()); + webRequest.getUrlEncodingCharset()); webRequest.setUrl(url); if (LOG.isDebugEnabled()) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-16 17:46:31 UTC (rev 15469) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2018-07-16 19:03:46 UTC (rev 15470) @@ -23,6 +23,7 @@ import java.net.IDN; import java.net.URL; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -430,6 +431,21 @@ } /** + * Returns the character set to use to encode the url params. + * @return the character set to use to encode the url params + */ + public Charset getUrlEncodingCharset() { + if (HttpMethod.GET == getHttpMethod() + || HttpMethod.DELETE == getHttpMethod() + || HttpMethod.HEAD == getHttpMethod() + || HttpMethod.OPTIONS == getHttpMethod() + || HttpMethod.TRACE == getHttpMethod()) { + return StandardCharsets.UTF_8; + } + return charset_; + } + + /** * Returns a string representation of this object. * @return a string representation of this object */ |
From: <rb...@us...> - 2018-07-16 17:46:34
|
Revision: 15469 http://sourceforge.net/p/htmlunit/code/15469 Author: rbri Date: 2018-07-16 17:46:31 +0000 (Mon, 16 Jul 2018) Log Message: ----------- httpclient update Modified Paths: -------------- trunk/htmlunit/pom.xml Modified: trunk/htmlunit/pom.xml =================================================================== --- trunk/htmlunit/pom.xml 2018-07-16 17:46:08 UTC (rev 15468) +++ trunk/htmlunit/pom.xml 2018-07-16 17:46:31 UTC (rev 15469) @@ -17,11 +17,11 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> <additionalparam>-Xdoclint:none</additionalparam> - <!-- As a property, as it is included in Checkstyle build --> - <checkstyle.version>8.10.1</checkstyle.version> <jetty.version>9.4.11.v20180605</jetty.version> <selenium.version>3.13.0</selenium.version> <htmlunitdriver.version>2.32.0-SNAPSHOT</htmlunitdriver.version> + <!-- As a property, as it is included in Checkstyle build --> + <checkstyle.version>8.11</checkstyle.version> </properties> <build> @@ -387,7 +387,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> - <version>2.9</version> + <version>3.0.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -847,12 +847,12 @@ <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> - <version>4.5.5</version> + <version>4.5.6</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> - <version>4.5.5</version> + <version>4.5.6</version> <type>test-jar</type> <scope>test</scope> <exclusions> |
From: <rb...@us...> - 2018-07-16 17:46:22
|
Revision: 15468 http://sourceforge.net/p/htmlunit/code/15468 Author: rbri Date: 2018-07-16 17:46:08 +0000 (Mon, 16 Jul 2018) Log Message: ----------- cleanup and ignore network problems Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java 2018-07-16 17:45:39 UTC (rev 15467) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ExternalTest.java 2018-07-16 17:46:08 UTC (rev 15468) @@ -87,9 +87,6 @@ } assertVersion("org.sonatype.oss", "oss-parent", "9"); - - assertChromeDriver(); - assertGeckoDriver(); } } @@ -106,7 +103,12 @@ } } - private static void assertChromeDriver() throws Exception { + /** + * Tests that we use the latest chrome driver. + * @throws Exception if an error occurs + */ + @Test + public void assertChromeDriver() throws Exception { try (WebClient webClient = getWebClient()) { final AbstractPage page = webClient.getPage("https://chromedriver.storage.googleapis.com/LATEST_RELEASE"); final String pageContent = page.getWebResponse().getContentAsString().trim(); @@ -114,11 +116,21 @@ } } - private static void assertGeckoDriver() throws Exception { + /** + * Tests that we use the latest gecko driver. + * @throws Exception if an error occurs + */ + @Test + public void assertGeckoDriver() throws Exception { try (WebClient webClient = getWebClient()) { - final HtmlPage page = webClient.getPage("https://github.com/mozilla/geckodriver/releases/latest"); - final DomNodeList<DomNode> divs = page.querySelectorAll(".release-title"); - assertEquals("Gecko Driver", divs.get(0).asText(), "v" + GECKO_DRIVER_); + try { + final HtmlPage page = webClient.getPage("https://github.com/mozilla/geckodriver/releases/latest"); + final DomNodeList<DomNode> divs = page.querySelectorAll(".release-title"); + assertEquals("Gecko Driver", divs.get(0).asText(), "v" + GECKO_DRIVER_); + } + catch (final FailingHttpStatusCodeException e) { + // ignore + } } } |
From: <rb...@us...> - 2018-07-16 17:45:44
|
Revision: 15467 http://sourceforge.net/p/htmlunit/code/15467 Author: rbri Date: 2018-07-16 17:45:39 +0000 (Mon, 16 Jul 2018) Log Message: ----------- make the encoding of parameters depending on the request type Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-16 16:18:48 UTC (rev 15466) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2018-07-16 17:45:39 UTC (rev 15467) @@ -28,6 +28,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -288,16 +289,28 @@ final Charset charset = webRequest.getCharset(); final HttpContext httpContext = getHttpContext(); + // Make sure that the URL is fully encoded. IE actually sends some Unicode chars in request // URLs; because of this we allow some Unicode chars in URLs. However, at this point we're // handing things over the HttpClient, and HttpClient will blow up if we leave these Unicode // chars in the URL. - final URL url = UrlUtils.encodeUrl(webRequest.getUrl(), false, charset); + final URL url; + if (HttpMethod.GET == webRequest.getHttpMethod() + || HttpMethod.DELETE == webRequest.getHttpMethod() + || HttpMethod.HEAD == webRequest.getHttpMethod() + || HttpMethod.OPTIONS == webRequest.getHttpMethod() + || HttpMethod.TRACE == webRequest.getHttpMethod()) { + url = UrlUtils.encodeUrl(webRequest.getUrl(), false, StandardCharsets.UTF_8); + } + else { + url = UrlUtils.encodeUrl(webRequest.getUrl(), false, charset); + } URI uri = UrlUtils.toURI(url, escapeQuery(url.getQuery())); if (getVirtualHost() != null) { uri = URI.create(getVirtualHost()); } + final HttpRequestBase httpMethod = buildHttpMethod(webRequest.getHttpMethod(), uri); setProxy(httpMethod, webRequest); if (!(httpMethod instanceof HttpEntityEnclosingRequest)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-16 16:18:48 UTC (rev 15466) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2018-07-16 17:45:39 UTC (rev 15467) @@ -36,7 +36,6 @@ import java.net.URLConnection; import java.net.URLDecoder; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; @@ -462,8 +461,6 @@ @SuppressWarnings("unchecked") public <P extends Page> P getPage(final URL url) throws IOException, FailingHttpStatusCodeException { final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); - request.setCharset(StandardCharsets.UTF_8); - return (P) getPage(getCurrentWindow().getTopWindow(), request); } @@ -884,7 +881,6 @@ if (url != null) { try { final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); - request.setCharset(StandardCharsets.UTF_8); if (getBrowserVersion().hasFeature(DIALOGWINDOW_REFERER) && openerPage != null) { @@ -1016,7 +1012,6 @@ final HtmlPage openerPage = (HtmlPage) opener.getEnclosedPage(); final WebRequest request = new WebRequest(url, getBrowserVersion().getHtmlAcceptHeader()); - request.setCharset(StandardCharsets.UTF_8); if (getBrowserVersion().hasFeature(DIALOGWINDOW_REFERER) && openerPage != null) { final String referer = openerPage.getUrl().toExternalForm(); |
From: <rb...@us...> - 2018-07-16 16:19:17
|
Revision: 15466 http://sourceforge.net/p/htmlunit/code/15466 Author: rbri Date: 2018-07-16 16:18:48 +0000 (Mon, 16 Jul 2018) Log Message: ----------- next step in our endless encoding fight Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2018-07-15 17:38:14 UTC (rev 15465) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection3Test.java 2018-07-16 16:18:48 UTC (rev 15466) @@ -16,9 +16,8 @@ import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; +import java.net.URLEncoder; import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; import org.junit.After; import org.junit.Test; @@ -157,14 +156,12 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "§§URL§§%D8%A3%D9%87%D9%84%D8%A7%D9%8B", - IE = "§§URL§§أهلاً") - @NotYetImplemented(IE) + @Alerts("§§URL§§?????") // seems to work only when running alone public void locationUTF() throws Exception { final String response = "HTTP/1.1 302 Found\r\n" + "Content-Length: 0\r\n" - + "Location: " + URL_FIRST + "أهلاً" + "\r\n" + + "Location: " + URL_FIRST + "\u0623\u0647\u0644\u0627\u064b" + "\r\n" + "\r\n"; final String response2 = "HTTP/1.1 200 OK\r\n" @@ -183,9 +180,7 @@ assertEquals(getExpectedAlerts()[0], driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("Hi")); - final List<String> requests = primitiveWebServer_.getRequests().stream().filter(r -> !r.contains("favicon.ico")) - .collect(Collectors.toList()); - assertEquals(2, requests.size()); + assertEquals(2, primitiveWebServer_.getRequests().size()); } /** @@ -194,14 +189,15 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "§§URL§§test?%D8%A3%D9%87%D9%84%D8%A7%D9%8B", - IE = "§§URL§§test?أهلاً") - @NotYetImplemented(IE) - // seems to work only when running alone - public void locationQueryUTF() throws Exception { + @Alerts("§§URL§§test?%D8%A3%D9%87%D9%84%D8%A7%D9%8B") + public void locationQueryUTF8Encoded() throws Exception { final String response = "HTTP/1.1 302 Found\r\n" + "Content-Length: 0\r\n" - + "Location: " + URL_FIRST + "test?أهلاً" + "\r\n" + + "Location: " + + URL_FIRST + + "test?" + + URLEncoder.encode("\u0623\u0647\u0644\u0627\u064b", "UTF-8") + + "\r\n" + "\r\n"; final String response2 = "HTTP/1.1 200 OK\r\n" @@ -220,12 +216,45 @@ assertEquals(getExpectedAlerts()[0], driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("Hi")); - final List<String> requests = primitiveWebServer_.getRequests().stream().filter(r -> !r.contains("favicon.ico")) - .collect(Collectors.toList()); - assertEquals(2, requests.size()); + assertEquals(2, primitiveWebServer_.getRequests().size()); } /** + * Test for bug #1898. + * + * @throws Exception if an error occurs + */ + @Test + @Alerts("§§URL§§%D8%A3%D9%87%D9%84%D8%A7%D9%8B") + public void locationUTF8Encoded() throws Exception { + final String response = "HTTP/1.1 302 Found\r\n" + + "Content-Length: 0\r\n" + + "Location: " + + URL_FIRST + + URLEncoder.encode("\u0623\u0647\u0644\u0627\u064b", "UTF-8") + + "\r\n" + + "\r\n"; + + final String response2 = "HTTP/1.1 200 OK\r\n" + + "Content-Length: 2\r\n" + + "Content-Type: text/html\r\n" + + "\r\n" + + "Hi"; + + expandExpectedAlertsVariables(URL_FIRST); + + primitiveWebServer_ = new PrimitiveWebServer(PORT, response, response2); + primitiveWebServer_.start(); + + final WebDriver driver = getWebDriver(); + driver.get(URL_FIRST.toExternalForm()); + assertEquals(getExpectedAlerts()[0], driver.getCurrentUrl()); + assertTrue(driver.getPageSource().contains("Hi")); + + assertEquals(2, primitiveWebServer_.getRequests().size()); + } + + /** * Test case for Bug #1882. * * @throws Exception if the test fails |
From: <rb...@us...> - 2018-07-15 17:38:19
|
Revision: 15465 http://sourceforge.net/p/htmlunit/code/15465 Author: rbri Date: 2018-07-15 17:38:14 +0000 (Sun, 15 Jul 2018) Log Message: ----------- next step in our endless encoding fight Modified Paths: -------------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebResponseTest.java Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-15 15:06:46 UTC (rev 15464) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PrimitiveWebServer.java 2018-07-15 17:38:14 UTC (rev 15465) @@ -38,7 +38,7 @@ private final String firstResponse_; private final String otherResponse_; private ServerSocket server_; - private Charset charset_ = StandardCharsets.UTF_8; + private Charset charset_ = StandardCharsets.ISO_8859_1; private List<String> requests_ = new ArrayList<>(); /** @@ -87,17 +87,27 @@ break; } } - requests_.add(writer.toString()); - try (OutputStream out = socket.getOutputStream()) { - final String response; - if (first || otherResponse_ == null) { - response = firstResponse_; + final String requestString = writer.toString(); + + final String response; + if (requestString.contains("/favicon.ico")) { + response = "HTTP/1.1 404 Not Found\r\n" + + "Content-Length: 0\r\n" + + "Content-Type: text/html; charset=iso-8859-1\r\n" + + "Connection: Closed\r\n\r\n"; + } + else { + requests_.add(writer.toString()); + try (OutputStream out = socket.getOutputStream()) { + if (first || otherResponse_ == null) { + response = firstResponse_; + } + else { + response = otherResponse_; + } + first = false; + out.write(response.getBytes(charset_)); } - else { - response = otherResponse_; - } - first = false; - out.write(response.getBytes(charset_)); } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-15 15:06:46 UTC (rev 15464) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient7Test.java 2018-07-15 17:38:14 UTC (rev 15465) @@ -158,8 +158,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "/bug.html?k%C3%B6nig", - IE = "/bug.html?k\u00c3\u00b6nig") + @Alerts(DEFAULT = "/bug.html?k%EF%BF%BDnig", + IE = "/bug.html?k\u00ef\u00bf\u00bdnig") @NotYetImplemented(IE) public void linkUrlEncodingUTF8() throws Exception { final String html = "<html>\n" @@ -176,14 +176,17 @@ + "\r\n" + html; - final String response = "HTTP/1.1 200 OK\r\n" - + "Content-Length: 2\r\n" + final String html2 = "<html><head><title>foo</title></head><body>" + + "</body></html>"; + + final String secondResponse = "HTTP/1.1 200 OK\r\n" + + "Content-Length: " + html2.length() + "\r\n" + "Content-Type: text/html\r\n" + "\r\n" - + "<html><head><title>foo</title></head><body>" - + "</body></html>"; + + html2; - primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, response); + primitiveWebServer_ = new PrimitiveWebServer(PORT, firstResponse, secondResponse); + primitiveWebServer_.setCharset(StandardCharsets.ISO_8859_1); primitiveWebServer_.start(); final WebDriver driver = getWebDriver(); @@ -192,9 +195,6 @@ driver.findElement(By.id("myLink")).click(); String reqUrl = primitiveWebServer_.getRequests().get(1); - if (reqUrl.contains("/favicon.ico")) { - reqUrl = primitiveWebServer_.getRequests().get(2); - } reqUrl = reqUrl.substring(4, reqUrl.indexOf("HTTP/1.1") - 1); assertEquals(getExpectedAlerts()[0], reqUrl); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java 2018-07-15 15:06:46 UTC (rev 15464) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java 2018-07-15 17:38:14 UTC (rev 15465) @@ -1641,7 +1641,7 @@ final URL url = new URL("http://host/x+y\u00E9/a\u00E9 b?c \u00E9 d"); final HtmlPage page = loadPage(BrowserVersion.FIREFOX_60, "<html></html>", new ArrayList<String>(), url); final WebRequest wrs = page.getWebResponse().getWebRequest(); - assertEquals("http://host/x+y%C3%A9/a%C3%A9%20b?c%20%E9%20d", wrs.getUrl()); + assertEquals("http://host/x+y%C3%A9/a%C3%A9%20b?c%20%C3%A9%20d", wrs.getUrl()); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebResponseTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebResponseTest.java 2018-07-15 15:06:46 UTC (rev 15464) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebResponseTest.java 2018-07-15 17:38:14 UTC (rev 15465) @@ -46,6 +46,7 @@ * * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class WebResponseTest extends WebServerTestCase { @@ -54,7 +55,7 @@ * @throws Exception if the test fails */ @Test - public void encoding() throws Exception { + public void encodingCharsetUtf8() throws Exception { final String title = "\u6211\u662F\u6211\u7684FOCUS"; final String content = "<html><head>\n" @@ -66,7 +67,7 @@ final WebClient client = getWebClient(); final MockWebConnection webConnection = new MockWebConnection(); - webConnection.setResponse(URL_FIRST, content.getBytes(UTF_8), 200, "OK", "text/html", null); + webConnection.setResponse(URL_FIRST, content.getBytes(UTF_8), 200, "OK", "text/html; charset=UTF-8", null); client.setWebConnection(webConnection); final WebRequest request = new WebRequest(URL_FIRST); request.setCharset(UTF_8); |