HttpComponents HttpClient
  1. HttpComponents HttpClient
  2. HTTPCLIENT-730

Use of Multi-Args URI Causes URI-Rewriting to improperly unescape characters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0 Alpha 2
    • Fix Version/s: 4.0 Alpha 3
    • Component/s: HttpClient
    • Labels:
      None

      Description

      See: http://www.nabble.com/unable-to-encode-reserved-characters-using-java.net.URI-multi-arg-constructors-td14954679.html for information from the httpclient-dev thread. The basic idea is that URI's multi-arg constructors break things.

        Activity

        Sam Berlin created issue -
        Hide
        Sam Berlin added a comment -

        A testcase specifically DefaultClientRequestDirector.rewriteRequestURI's else branch. I'm not positive how to setup the environment to test the if branch. There's still three of untested uses of URI's multi-arg constructor, but this is a good easy-to-test first step.

        Show
        Sam Berlin added a comment - A testcase specifically DefaultClientRequestDirector.rewriteRequestURI's else branch. I'm not positive how to setup the environment to test the if branch. There's still three of untested uses of URI's multi-arg constructor, but this is a good easy-to-test first step.
        Sam Berlin made changes -
        Field Original Value New Value
        Attachment TestUriEscapes.java [ 12373758 ]
        Hide
        Sam Berlin added a comment -

        Per the email thread, placing


        String path = uri.getRawPath();
        String query = uri.getRawQuery();
        String fragment = uri.getRawFragment();
        String newUri =
        (path == null ? "" : path)
        + (query == null ? "" : ("?" + query))
        + (fragment == null ? "" : ("#" + fragment));
        request.setURI(new URI(newUri));

        in DefaultClientRequestDirector.rewriteRequestURI else if branch will fix it, but I don't know how stable that is.

        Show
        Sam Berlin added a comment - Per the email thread, placing String path = uri.getRawPath(); String query = uri.getRawQuery(); String fragment = uri.getRawFragment(); String newUri = (path == null ? "" : path) + (query == null ? "" : ("?" + query)) + (fragment == null ? "" : ("#" + fragment)); request.setURI(new URI(newUri)); – in DefaultClientRequestDirector.rewriteRequestURI else if branch will fix it, but I don't know how stable that is.
        Hide
        Tim Julien added a comment -

        could probably steal java.net.URI.defineString() for a general purpose method to build a complete String URI to be used in conjunction with java.net.URI(String s)

        Show
        Tim Julien added a comment - could probably steal java.net.URI.defineString() for a general purpose method to build a complete String URI to be used in conjunction with java.net.URI(String s)
        Hide
        Oleg Kalnichevski added a comment -

        Applied a fixed similar to that suggested by Sam. All tests pass for me now. Please review.

        Oleg

        Show
        Oleg Kalnichevski added a comment - Applied a fixed similar to that suggested by Sam. All tests pass for me now. Please review. Oleg
        Oleg Kalnichevski made changes -
        Fix Version/s 4.0 Alpha 3 [ 12312697 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Oleg Kalnichevski made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12421751 ] Default workflow, editable Closed status [ 12557904 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12557904 ] jira [ 12581084 ]
        Mark Thomas made changes -
        Workflow jira [ 12581084 ] Default workflow, editable Closed status [ 12606879 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        2d 2h 49m 1 Oleg Kalnichevski 24/Jan/08 16:54
        Resolved Resolved Closed Closed
        1096d 18h 4m 1 Oleg Kalnichevski 25/Jan/11 10:58

          People

          • Assignee:
            Unassigned
            Reporter:
            Sam Berlin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development