Jetty
  1. Jetty
  2. JETTY-1390

Rewrite handler does not handle encoded URIs correctly

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.26
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      1> Configure the RewriteHandler in jetty.xml as follows.

      <Set name="handler">
      <New id="Handlers"
      class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>
      <Call name="addRule"><Arg><New
      class="org.mortbay.jetty.handler.rewrite.MsieSslRule"/></Arg></Call>
      <!-- map convenience URLs to the webapp that handles them -->
      <Call
      name="addRewriteRule"><Arg>/foo/*</Arg><Arg>/service/foo</Arg></Call>
      </New>
      </Set>

      2> Configure a Servlet to handle requests sent to /service/foo

      3> Send the request as http://<host>:<port>/service/foo/a%2Fb
      request.getRequestURI() on the Servlet returns "/service/foo/a%2Fb".
      This is correct.

      4> Send the request as http://<host>:<port>/foo/a%2Fb
      request.getRequestURI() on the Servlet returns "/service/foo/a/b".
      This is wrong, it should be "/service/foo/a%2Fb

        Activity

        Michael Gorovoy made changes -
        Field Original Value New Value
        Assignee Michael Gorovoy [ mgorovoy ]
        Michael Gorovoy made changes -
        Affects Version/s 6.1.26 [ 16660 ]
        Description
        1> Configure the RewriteHandler in jetty.xml as follows.

            <Set name="handler">
              <New id="Handlers"
        class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
                <Set name="rewriteRequestURI">true</Set>
                <Set name="rewritePathInfo">false</Set>
                <Set name="originalPathAttribute">requestedPath</Set>
                    <Call name="addRule"><Arg><New
        class="org.mortbay.jetty.handler.rewrite.MsieSslRule"/></Arg></Call>
                <!-- map convenience URLs to the webapp that handles them -->
                <Call
        name="addRewriteRule"><Arg>/foo/*</Arg><Arg>/service/foo</Arg></Call>
              </New>
           </Set>

        2> Configure a Servlet to handle requests sent to /service/foo

        3> Send the request as http://&lt;host&gt;:&lt;port&gt;/service/foo/a%2Fb
                  request.getRequestURI() on the Servlet returns "/service/foo/a%2Fb".
        This is correct.

        4> Send the request as http://&lt;host&gt;:&lt;port&gt;/foo/a%2Fb
                  request.getRequestURI() on the Servlet returns "/service/foo/a/b".
        This is wrong, it should be "/service/foo/a%2Fb

        1> Configure the RewriteHandler in jetty.xml as follows.

            <Set name="handler">
              <New id="Handlers"
        class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
                <Set name="rewriteRequestURI">true</Set>
                <Set name="rewritePathInfo">false</Set>
                <Set name="originalPathAttribute">requestedPath</Set>
                    <Call name="addRule"><Arg><New
        class="org.mortbay.jetty.handler.rewrite.MsieSslRule"/></Arg></Call>
                <!-- map convenience URLs to the webapp that handles them -->
                <Call
        name="addRewriteRule"><Arg>/foo/*</Arg><Arg>/service/foo</Arg></Call>
              </New>
           </Set>

        2> Configure a Servlet to handle requests sent to /service/foo

        3> Send the request as http://&lt;host&gt;:&lt;port&gt;/service/foo/a%2Fb
                  request.getRequestURI() on the Servlet returns "/service/foo/a%2Fb".
        This is correct.

        4> Send the request as http://&lt;host&gt;:&lt;port&gt;/foo/a%2Fb
                  request.getRequestURI() on the Servlet returns "/service/foo/a/b".
        This is wrong, it should be "/service/foo/a%2Fb

        Michael Gorovoy made changes -
        Summary Rewrite handler does not handle encoded URIs Rewrite handler does not handle encoded URIs correctly
        Michael Gorovoy made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Michael Gorovoy
            Reporter:
            Greg Wilkins
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: