Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3411

query string decoding error in URLHelper.parseQueryString

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.8.1
    • 2.2.1
    • None
    • None
    • Patch

    Description

      There is a bug in URLHelper.parseQueryString() when dealing with keys in a query string that are URL Encoded.

      Example:
      UrlHelper.parseQueryString("a%3Ca=1") returns a map

      {"a%3Ca" : "1"}

      . Note, the key is still URL Encoded.

      The problem becomes apparent if you use <s:url> with includeParams="all", which will grab parameters from both the query string and request parameterMap to include into a URL.

      Example:
      Request URL: /myAction.action?a<a=1
      Generated URL by <s:url>: /myAction.action?a<a=1&a%3Ca=1
      Expected URL: /myAction.action?a%3Ca=1

      Note how "a<a" exists two times in the <s:url> URL, one encoded and one decoded. "a<a" is grabbed from the parameterMap where the servlet container will automatically decode the key. "a%3Ca" is grabbed from the query string by the UrlHelper.parseQueryString (who doesn't decode the key).

      The fix is relatively simple (see patch)... I think parseQueryString just needs to call translatedAndDecode on the parameter name.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            sford Sean Ford
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: