Uploaded image for project: 'OpenDJ'
  1. OpenDJ
  2. OPENDJ-1212

Embedded HTTP listener decodes URL parameters as iso-8859-1 by default

    XMLWordPrintable

Details

    • Bug
    • Status: Done
    • Major
    • Resolution: Fixed
    • 2.6.0
    • 2.6.1, 2.8.0, 3.0.0
    • rest
    • None

    Description

      Using the embedded listener this works:

      curl -v 'http://bjensen:hifalutin@localhost:8000/users?_queryFilter=/name/givenName+eq+"Fred%e9rique"&_prettyPrint=true'
      

      Whereas the Servlet requires that non-ascii characters be encoded as UTF-8:

      curl -v 'http://bjensen:hifalutin@localhost:8000/users?_queryFilter=/name/givenName+eq+"Fred%c3%a9rique"&_prettyPrint=true'
      

      The URI encoding RFC indicates that the Servlet is correct:

      http://tools.ietf.org/html/rfc3986#section-2.5

      In addition, since non-ASCII characters do not need to be encoded if they are in the query string it is legal to use a URL like this:

      curl -v 'http://bjensen:hifalutin@localhost:8000/users?_queryFilter=/name/givenName+eq+"Fredérique"&_prettyPrint=true'
      

      Again, this URL works with the Servlet but not the embedded listener, which seems to double encode the non-ASCII characters.

      The problem resides in our use of Grizzly: the Servlet tests above were done using Jetty 9 which is to be compliant. Grizzly, on the other hand, uses ISO-8859-1 by default. It is possible to override the default by passing in the following HTTP header:

      application/json;charset=UTF-8
      

      It looks like the problem is here:

      org.glassfish.grizzly.http.util.Constants.DEFAULT_HTTP_CHARACTER_ENCODING
          /**
           * Default HTTP character encoding
           * TODO Grizzly 2.0, by default, parsed the request URI using UTF-8.
           * We should probably do so with query parameters
           */
          public static final String DEFAULT_HTTP_CHARACTER_ENCODING = "ISO-8859-1";
      

      Attachments

        Activity

          People

            matthew Matthew Swift
            matthew Matthew Swift
            Matthew Swift Matthew Swift
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: