Jetty
  1. Jetty
  2. JETTY-1328

org.mortbay.jetty.HttpConnection.printWriter("UTF-8") returns a broken UTF-8 writer wrt. Strings containing surrogate characters

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.14
    • Fix Version/s: 6.1.27
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      2

      Description

      I've attached Surrogates.java which demonstrates the problem.

      pw = HttpConnection.printWriter("UTF-8");
      String a = new String("<?xml version=\"1.0\" ?><root>\uDBB8\uDF30</root>");
      pw.write(alpha);

      Both the low and high surrogate characters are encoded as utf-8. They need to be combined per utf-8 spec.
      A: Surrogates are code points from two special ranges of Unicode values, reserved for use as the leading, and trailing values of paired code units in UTF-16. Leading, also called high, surrogates are from D80016 to DBFF16, and trailing, or low, surrogates are from DC0016 to DFFF16. They are called surrogates, since they do not represent characters directly, but only as a pair.

      I've also attached a AbstractGenerator.java with a working fix. But you guys might want to refactor. I didn't see a fix in subsequent versions of Jetty.

      1. AbstractGenerator.java
        31 kB
        Alex Makarewycz
      2. Surrogates.java
        3 kB
        Alex Makarewycz

        Issue Links

          Activity

            People

            • Assignee:
              Greg Wilkins
              Reporter:
              Alex Makarewycz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: