Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1070

rewrite handler produces invalid URLs when used with query part

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.0.0.Beta1, 1.4.15.Final
    • None
    • None
    • None
    • Hide

      Undertow configuration (relevant parts only):

             <subsystem xmlns="urn:jboss:domain:undertow:3.1">
                  <buffer-cache name="default"/>
                  <server name="default-server">
                      <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
                      <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
      
                      <host name="default-host" alias="localhost, home">
                          <access-log pattern="Def: %h %t %v &quot;%r&quot; %s " use-server-log="true"/>
                          <filter-ref name="to-query0" predicate="regex('^/?$') and equals(%{LOCAL_SERVER_NAME}, 'home:8180')"/>
                      </host>
                  </server>
                  <filters>
                      <rewrite name="to-query0" target="/somepath?param=1234"/>
                      <expression-filter name="to-query1" expression="rewrite('/somepath?param=1234')"/>
                      <expression-filter name="to-query2" expression="rewrite('/somepath'); set(attribute='%{q,param}', value='1234')"/>
                      <expression-filter name="to-query3" expression="rewrite('/somepath'); set(attribute='%{QUERY_STRING}', value='param=1234')"/>
                      <expression-filter name="to-query4" expression="set(attribute='%{RELATIVE_PATH}', value='/somepath'); set(attribute='%{QUERY_STRING}', value='param=1234')"/>
                  </filters>
              </subsystem>
      

      Results of the different filters:

      // erroneous
      to-query0: /somepath?param=1234??param=1234
      to-query1: /somepath?param=1234??param=1234
      to-query2: /somepath
      // as expected
      to-query3: /somepath?param=1234
      to-query4: /somepath?param=1234
      
      Show
      Undertow configuration (relevant parts only): <subsystem xmlns= "urn:jboss:domain:undertow:3.1" > <buffer-cache name= " default " /> <server name= " default -server" > <http-listener name= " default " socket-binding= "http" redirect-socket= "https" enable-http2= " true " /> <https-listener name= "https" socket-binding= "https" security-realm= "ApplicationRealm" enable-http2= " true " /> <host name= " default -host" alias= "localhost, home" > <access-log pattern= "Def: %h %t %v &quot;%r&quot; %s " use-server-log= " true " /> <filter-ref name= "to-query0" predicate= "regex( '^/?$' ) and equals(%{LOCAL_SERVER_NAME}, 'home:8180' )" /> </host> </server> <filters> <rewrite name= "to-query0" target= "/somepath?param=1234" /> <expression-filter name= "to-query1" expression= "rewrite( '/somepath?param=1234' )" /> <expression-filter name= "to-query2" expression= "rewrite( '/somepath' ); set(attribute= '%{q,param}' , value= '1234' )" /> <expression-filter name= "to-query3" expression= "rewrite( '/somepath' ); set(attribute= '%{QUERY_STRING}' , value= 'param=1234' )" /> <expression-filter name= "to-query4" expression= "set(attribute= '%{RELATIVE_PATH}' , value= '/somepath' ); set(attribute= '%{QUERY_STRING}' , value= 'param=1234' )" /> </filters> </subsystem> Results of the different filters: // erroneous to-query0: /somepath?param=1234??param=1234 to-query1: /somepath?param=1234??param=1234 to-query2: /somepath // as expected to-query3: /somepath?param=1234 to-query4: /somepath?param=1234
    • Workaround Exists
    • Hide

      use filter in the form of "to-query3"

      Show
      use filter in the form of "to-query3"

    Description

      Context:
      a request of the form "http://home:8180/" should be rewritten to "http://home:8180/somepath?param=1234"

      Problem:
      The rewrite handler produces URLs which contain duplicated query parts and question marks. See excerpt from access log below.

      [26/Apr/2017:09:26:09 +0200] home:8180 "GET /somepath?param=1234??param=1234 HTTP/1.1" 404
      

      Attachments

        Issue Links

          Activity

            People

              sdouglas1@redhat.com Stuart Douglas
              mrkstr Markus Stier (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: