Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2012

URIBuilder#setPathSegments Doesn't URL-encode Reserved Characters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.5.9
    • Fix Version/s: None
    • Component/s: HttpClient (classic)
    • Labels:
      None

      Description

      I found this bug while debugging a failing WireMock test, but the gist is as follows:

       

      Generate a request which has reserved, but encoded, characters in the path, for example:

       

      `http://localhost:8080/api/1234%3A1a2b3c/action`

       

      This request will be properly encoded when being sent to HTTPClient via Spring's resttemplate. Since request normalization is enabled by default, the request URI is torn down and re-constructed; however, when expanding the path segments, the `%3A` is decoded to a colon `:`, and when the path segments are reconstituted via #setPathSegments, the reserved character isn't re-encoded, resulting in an improperly formatted outbound request. 

       

      I believe this can be mitigated via disabling normalization in the request context; however, it's a nasty surprise. 

       

      The offending lines appear to be 219-228 in URIUtils.java for version 4.5.9 (version I tested with).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                krooj Michael Kuredjian
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: