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

UriBuilder.fromUri does not accept colons in relative paths

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.11.Final
    • 3.0.6.Final, 3.0.8.Final
    • jaxrs
    • None
    • Hide
      javax.ws.rs.core.UriBuilder.fromUri("foo/bar:id")
      
      Show
      javax.ws.rs.core.UriBuilder.fromUri( "foo/bar:id" )

      When calling UriBuilder with a relative path that contains one or more colons, it fails with an IllegalArgumentException.

      javax.ws.rs.core.UriBuilder.fromUri("foo/bar:id")
      

      java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id
      	at org.jboss.resteasy.specimpl.ResteasyUriBuilder.parseHierarchicalUri(ResteasyUriBuilder.java:177)
      	at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uriTemplate(ResteasyUriBuilder.java:135)
      	at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uri(ResteasyUriBuilder.java:188)
      	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
      

      if (!scheme && !"".equals(group) && !group.startsWith("/") && group.indexOf(':') > -1) throw new IllegalArgumentException("Illegal uri template: " + uriTemplate);
      

      This line in org.jboss.resteasy.specimpl.ResteasyUriBuilder#parseHierarchicalUri checks explicitly if a colon is contained in the path and throws this exception. According to http://tools.ietf.org/html/rfc3986#appendix-A the colon is allowed in the path at this position. For path-noscheme only the first segment MUST NOT contain a colon, every following segment can contain pchar* including colon.

         path          = path-abempty    ; begins with "/" or is empty
                       / path-absolute   ; begins with "/" but not "//"
                       / path-noscheme   ; begins with a non-colon segment
                       / path-rootless   ; begins with a segment
                       / path-empty      ; zero characters
      
         path-abempty  = *( "/" segment )
         path-absolute = "/" [ segment-nz *( "/" segment ) ]
         path-noscheme = segment-nz-nc *( "/" segment )
         path-rootless = segment-nz *( "/" segment )
         path-empty    = 0<pchar>
      
         segment       = *pchar
         segment-nz    = 1*pchar
         segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
                       ; non-zero-length segment without any colon ":"
      
         pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
      

      This bug causes org.jboss.resteasy.mock.MockHttpRequest#initWithUri(java.lang.String) to fail for relative URIs that contain colons.

              patriot1burke@gmail.com Bill Burke (Inactive)
              leonard84_jira Leonard Brünings (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: