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

Predicate Language rewrite handler mishandles ? in query string

    XMLWordPrintable

Details

    Description

      When using the rewrite() handler with a query string like so:

      regex('^/jobs/([^/]+)/?(.*)$') -> rewrite('/jobseekers/home.cfm?joblocation=${1}');
      

      the RelativePathAttribute mishandles the ? and leaves it in the query string which causes the final URL inside the exchange to have two question marks. 

      /jobseekers/home.cfm??joblocation=atlanta
      

      The work around for now is to set the query string via a separate handler

      regex('^/jobs/([^/]+)/?(.*)$') -> {
        rewrite('/jobseekers/home.cfm');
        set(attribute='%{QUERY_STRING}', value='joblocation=${1}')
      }
      

      On a related note, the QueryStringAttribute has a similar inconsistency where it includes the ? when reading the query string, but will not remove an incoming ? when writing the attribute.  I would recommend having the ? cleaned off when writing for consistency between reading and writing the attribute.  

      In actuality, both of the issues above can be solved in one go if the HTTPServerExchange simply removes any leading ? from the start of a query string in the setQueryString() method since both the RelativePathAttribute and the QueryStringAttribute are calling that method to set their query string.

       

      Attachments

        Issue Links

          Activity

            People

              rhn-cservice-bbaranow Bartosz Baranowski
              bdw429s Brad Wood
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: