-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulestatus: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regressionA bug that is also a regression
Milestone
Description
Affects: 5.0.2 - 5.2.5
The latest versions of spring-test since 5.0.2 don't include the IPV6 address in the getRequestURL() in correct []-quoting.
For example if the MockHttpServletRequest is constructed using "GET", "/" and then the server name is set with a call to setServerName("::ffff:abcd:abcd"), then getRequestURL() returns "http://[::ffff:abcd:abcd]/" in the old versions, but latest versions return "http://::ffff:abcd:abcd/" which cannot be parsed by java.net.URL.
The problem seems to happen in the getRequestURL() implementation which uses getServerName() and does not check if the serverName is actually IPV6 address which should be quoted with brackets.
See RFC 2732 for reference.
@Test public void testIPV6() { String ipv6 = "::ffff:abcd:abcd"; MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.addHeader("Host", "["+ipv6+"]"); request.setServerName("["+ipv6+"]"); String urlString = request.getRequestURL().toString(); System.out.println("#URL: \"" + urlString+"\""); // The URL should look like: "http://[::ffff:abcd:abcd]/" try { java.net.URL url = new java.net.URL(urlString); } catch (java.net.MalformedURLException e) { assertEquals(e, null); } }Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulestatus: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regressionA bug that is also a regression