javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1516

Ajax response needs to allow for non-UTF-8 charset

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.3-b01
    • Component/s: ajax
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,516

      Description

      From the forums:

      http://forums.java.net/jive/thread.jspa?threadID=73023&tstart=0

      taikaviitta

      Posts: 1

      Ajax partial response encoding issue
      Posted: Jan 21, 2010 1:05 AM

      During response rendering ajax request performs rendering by using the encoding
      from the request. However, the encoding in the partial response document is
      hardcoded to UTF-8 which leads to problems at least with certain browsers (e.g.
      IE). Lets assume the request comes in with ISO-8859-1 and thus the response with
      current code looks like this:

      <?xml version="1.0" encoding="utf-8"?>
      <partial-response>...</partial-response>

      If I have content with for example scandinavian alphabets (åäö), the response
      document causes problems in the browser: HTTP headers state that encoding is
      ISO-8859-1, the XML document states encoding is UTF-8 but the content is encoded
      with ISO-8859-1. This clearly violates encoding rules. I made a little change to
      PartialResponseWriter which seem to work pretty nicely and fixes this problem.

      Current code:

      public void startDocument() throws IOException {
      ResponseWriter writer = getWrapped();
      writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
      writer.startElement("partial-response", null);
      }

      And the new code looks like this:

      public void startDocument() throws IOException {
      ResponseWriter writer = getWrapped();
      // PACI 20.1.2010

      { String encoding = writer.getCharacterEncoding( ); if( encoding == null ) encoding = "utf-8"; writer.write("<?xml version='1.0' encoding='" + encoding + "'?>\n"); // }

      PACI 20.1.2010
      writer.startElement("partial-response", null);
      }

      Cheers,

      Paci

        Activity

        Hide
        driscoll added a comment -

        Target 2.0.3.

        Take ownership.

        Show
        driscoll added a comment - Target 2.0.3. Take ownership.
        Hide
        driscoll added a comment -

        Changes applied. (r8295)

        Show
        driscoll added a comment - Changes applied. (r8295)
        Hide
        Manfred Riem added a comment -

        Closing resolved issue out

        Show
        Manfred Riem added a comment - Closing resolved issue out

          People

          • Assignee:
            driscoll
            Reporter:
            driscoll
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: