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

IllegalArgumentException when a template parameter value contains a dollar sign

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.3-beta-1
    • 2.2.2.GA
    • None
    • None
    • Hide

      The following code produces the exception

      System.out.println(UriBuilder.fromPath("/{p}").build("$a"));
      

      Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
      at java.util.regex.Matcher.appendReplacement(Matcher.java:713)
      at org.jboss.resteasy.specimpl.UriBuilderImpl.replaceParameter(UriBuilderImpl.java:463)
      at org.jboss.resteasy.specimpl.UriBuilderImpl.buildFromMap(UriBuilderImpl.java:383)
      at org.jboss.resteasy.specimpl.UriBuilderImpl.buildFromValues(UriBuilderImpl.java:558)
      at org.jboss.resteasy.specimpl.UriBuilderImpl.build(UriBuilderImpl.java:539)

      Show
      The following code produces the exception System .out.println(UriBuilder.fromPath( "/{p}" ).build( "$a" )); Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:713) at org.jboss.resteasy.specimpl.UriBuilderImpl.replaceParameter(UriBuilderImpl.java:463) at org.jboss.resteasy.specimpl.UriBuilderImpl.buildFromMap(UriBuilderImpl.java:383) at org.jboss.resteasy.specimpl.UriBuilderImpl.buildFromValues(UriBuilderImpl.java:558) at org.jboss.resteasy.specimpl.UriBuilderImpl.build(UriBuilderImpl.java:539)

    Description

      Method UriBuilder.build throws an IllegalArgumentException when a value for a template parameter in the URI path contains a dollar mark:

      UriBuilder.fromPath("/{p}").build("$a");
      

      The reason is that UriBuilderImpl.java does not apply proper quoting on line 463

      matcher.appendReplacement(buffer, value);
      

      which can be fixed like this

      matcher.appendReplacement(buffer, Matcher.quoteReplacement(value));
      

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            tarasp Taras Puchko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: