ServletWebRequest#getContextRelativeUrl() passes "foo://:/" to Url#parse() and that one fails.

Please create a Jira issue.

Sven

On 07/24/2013 05:06 PM, Martin Funk wrote:
Hi Sven,

we still can reproduce this on any version.

Maybe this git diff gives a clearer picture:

diff --git
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
index f974a06..9ee3308 100644
---
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
+++
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
@@ -191,6 +191,16 @@
   assertEquals("any/source/of/error", errorClientUrl.toString());
   }

+ @Test
+ public void wicketFoo()
+ {
+ String filterPath = "filterPath";
+ MockHttpServletRequest httpRequest = new MockHttpServletRequest(null,
null, null);
+ httpRequest.setURL("http://localhost"; + '/' + filterPath +
"/request/foo://:/");
+
+ ServletWebRequest webRequest = new ServletWebRequest(httpRequest,
filterPath);
+ }
+
   private static class CustomRequestPage extends WebPage implements
IMarkupResourceStreamProvider
   {
   private static final long serialVersionUID = 1L;

This tests leads to this exption

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.wicket.request.Url.parse(Url.java:277)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:208)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:112)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:82)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequestTest.wicketFoo(ServletWebRequestTest.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

cheers,


Martin



2013/7/24 Mathias Binder <mailto...@gmail.com>

We work with Version 6.7.0

Mathias

2013/7/24 Sven Meier <s...@meiers.net>:
Hi,

which Wicket version? Url parsing has been improved on lately:

     @Test
     public void weirdUrl()
     {
         Url url = Url.parse("http://wicket.apache.org/h@@p://h@@p://";);

         assertEquals("wicket.apache.org", url.getHost());
         assertEquals("/h@@p://h@@p://", url.getPath());
     }


Works fine with 6.10.0-SNAPSHOT.

Sven


On 07/24/2013 10:29 AM, Mathias Binder wrote:
Hi,

we became aware of a problem caused by requests with invalid URIs on
our wicket-application. The URI contains strings like "*://*:*", so
wicket tries to determine and parse a port number, that is not
present. This leads to NumberFormatExceptions with URIs like, e.g.
http://<host>/h@@p://h@@p://

java.lang.NumberFormatException: For input string: ""


java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:470)
java.lang.Integer.parseInt(Integer.java:499)
org.apache.wicket.request.Url.parse(Url.java:197)


org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)

org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:126)

org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:83)

org.apache.wicket.protocol.http.WebApplication.newWebRequest(WebApplication.java:413)

org.apache.wicket.protocol.http.WebApplication.createWebRequest(WebApplication.java:458)

org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:183)

org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)

Should this issue be fixed in the URL representation from wicket?
Something like a check if the string that represents the port-number
to be parsed is not emtpy?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to