Wicket
  1. Wicket
  2. WICKET-5287

NumberFormatException when parsing the port from Requests with invalid URIs

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.10, 6.9.1
    • Fix Version/s: 6.10.0, 7.0.0-M1
    • Component/s: None
    • Labels:
      None

      Description

      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)

        Issue Links

          Activity

          Martin Grigorov made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 7.0.0 [ 12322958 ]
          Fix Version/s 6.10.0 [ 12324643 ]
          Resolution Fixed [ 1 ]
          Martin Grigorov made changes -
          Summary NumberFormatException from Requests with invalid URIs NumberFormatException when parsing the port from Requests with invalid URIs
          Martin Grigorov made changes -
          Assignee Martin Grigorov [ mgrigorov ]
          Martin Grigorov made changes -
          Field Original Value New Value
          Remote Link This issue links to "Mail discussion (Web Link)" [ 12507 ]
          Martin Funk created issue -

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Martin Funk
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development