Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8198812

jdk.incubator.httpclient URI query string is truncated when containing an encoded reserved character

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      FULL PRODUCT VERSION :
      java version "9.0.4"
      Java(TM) SE Runtime Environment (build 9.0.4+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux PROJ093 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Example URI string parsed by new URI(string) that contains an encoded reserved character "#" (%23) in the query string:

      http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-8541-fa5ea6d6567a?predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody

      The URI object is then simply passed to HttpRequest.newBuilder(uri)

      The server response shows this:
      127.0.0.1 - - [22/Feb/2018:10:30:51 +0000] "GET /ldp-test-43272e5c-
      1e3f-4bb8-8541-fa5ea6d6567a?predicate=http://www.w3.org/ns/oa
      HTTP/1.1" 200 3 "-" "-" 64

      Note that the encoded query param value for predicate seems to have been decoded and the string is truncated from the "#" to the end.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      final String predicate = URLEncoder.encode("http://www.w3.org/ns/oa#hasBody", StandardCharsets.UTF_8.toString());
      final URI uri = new URI(identifier + "?predicate=" + predicate);
      final HttpRequest req = HttpRequest.newBuilder(uri).GET().build();
      final HttpResponse<String> response = client.send(req, asString());

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      127.0.0.1 - - [22/Feb/2018:10:30:51 +0000] "GET /ldp-test-43272e5c-
      1e3f-4bb8-8541-fa5ea6d6567a?predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
      HTTP/1.1" 200 795 "-" "-" 64
      ACTUAL -
      127.0.0.1 - - [22/Feb/2018:10:30:51 +0000] "GET /ldp-test-43272e5c-
      1e3f-4bb8-8541-fa5ea6d6567a?predicate=http://www.w3.org/ns/oa
      HTTP/1.1" 200 3 "-" "-" 64

      REPRODUCIBILITY :
      This bug can be reproduced always.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: