Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-214

RestEasy Client encodes the path parameters with white chars incorrectly.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 1.1.RC1
    • 1.0.2.GA
    • jaxrs
    • None

    Description

      RestEasy Client encodes the path parameters with white chars incorrectly.

      SCENARIO to reproduce:

      1. Using RestEasy Client call a REST method with a path parameter. Set the value of this path parameter to:
      'something something'

      2. Display/trace the decoded value of this parameter on the server side.

      RESULT: The displayed path parameter on the server side is incorrect and different than the original one.
      'something%20something'

      EXPECTED RESULT:
      The displayed, decoded path parameter should be 'something something'!

      SOLUTION:
      I found the suspected code in the class: ./resteasy-jaxrs-1-1/resteasy-jaxrs/src/main/java/org/jboss/resteasy/specimpl/UriBuilderImpl.java

      ORIGINAL CODE:
      //protected StringBuffer replaceParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer)
      //{
      // Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(string);
      // while (matcher.find())
      //

      { // String param = matcher.group(1); // if (!param.equals(name)) continue; // value = Encode.encodeSegment(value, false); // if (!isEncoded) value = value.replace("%", "%25"); // else Encode.encodeNonCodes(value); // matcher.appendReplacement(buffer, value); // }

      // matcher.appendTail(buffer);
      // return buffer;
      //}

      PROPOSED CODE:
      //protected StringBuffer replaceParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer)
      //{
      // Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(string);
      // while (matcher.find())
      // {
      // String param = matcher.group(1);
      // if (!param.equals(name)) continue;
      //
      // if (!isEncoded)

      { value = value.replace("%", "%25"); // value = Encode.encodeSegment(value, false); // }

      // else
      // value = Encode.encodeNonCodes(value);
      // matcher.appendReplacement(buffer, value);
      // }
      // matcher.appendTail(buffer);
      // return buffer;
      //}

      The example project containing a simple echo server and test reproducing the problem is attached. It can be build using maven.

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            agnieszka.michalik Agnieszka Michalik (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: