jersey
  1. jersey
  2. JERSEY-1805

UriBuilder incorrectly encoding Query Parameters value for % character.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.17
    • Fix Version/s: 1.18, 2.0-rc2
    • Component/s: core
    • Labels:
      None

      Description

      URI Builder does not encode correctly value objects containing character % .

      String test = UriBuilder.fromPath("https://dummy.com").
      queryParam("param", "%dummy23").
      build().toURL().toString();

      The encoded string is https://dummy.com?param=%dummy23

      The expected URI should be https://dummy.com?param=%25dummy23

        Issue Links

          Activity

          Hide
          Marek Potociar added a comment -

          See also and fix issues reported in duplicate issue JERSEY-1717.

          Show
          Marek Potociar added a comment - See also and fix issues reported in duplicate issue JERSEY-1717 .
          Hide
          Miroslav Fuksa added a comment -

          Cannot reproduce bug in Jersey 1.18 neither in jersey 2.rc1. Tests added to both.

          Show
          Miroslav Fuksa added a comment - Cannot reproduce bug in Jersey 1.18 neither in jersey 2.rc1. Tests added to both.
          Hide
          Miroslav Fuksa added a comment -

          This bug was Closed but should be Resolved.

          Show
          Miroslav Fuksa added a comment - This bug was Closed but should be Resolved.
          Hide
          Carlos Santos added a comment -

          I run into this problem but not with the String mentioned in the description. Instead, with "%AD".

          String test = UriBuilder.fromPath("https://dummy.com").queryParam("param", "%AD").build().toURL().toString();

          The encoded String is https://dummy.com?param=%AD
          The expected URI should be https://dummy.com?param=%25AD

          The method queryParam(...) only behaves like this when the two characters following the "%" are hexadecimal. I.e, the method "com.sun.jersey.api.uri.UriComponent.isHexCharacter(char)" returns true for the characters following the "%".

          I am afraid the behavior of UriBuilderImpl is correct because it tries to guess when a parameter is already encoded.

          I am not sure if its ok to comment in a closed issue. Sorry if it is not.
          Should I create a new issue or ask in the Jersey's mailing list first?

          Show
          Carlos Santos added a comment - I run into this problem but not with the String mentioned in the description. Instead, with "%AD". String test = UriBuilder.fromPath("https://dummy.com").queryParam("param", "%AD").build().toURL().toString(); The encoded String is https://dummy.com?param=%AD The expected URI should be https://dummy.com?param=%25AD The method queryParam(...) only behaves like this when the two characters following the "%" are hexadecimal. I.e, the method "com.sun.jersey.api.uri.UriComponent.isHexCharacter(char)" returns true for the characters following the "%". I am afraid the behavior of UriBuilderImpl is correct because it tries to guess when a parameter is already encoded. I am not sure if its ok to comment in a closed issue. Sorry if it is not. Should I create a new issue or ask in the Jersey's mailing list first?

            People

            • Assignee:
              Miroslav Fuksa
              Reporter:
              b0ris_1
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 30 minutes
                4h 30m