Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-8641

rewrite handler produces invalid URLs when used with query part

    Details

    • Steps to Reproduce:
      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:
      Workaround Exists
    • Workaround Description:
      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
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swd847 Stuart Douglas
                  Reporter:
                  mrkstr Markus Stier
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: