Solr
  1. Solr
  2. SOLR-1936

Json output Incorrect escaping Unicode Character 'LINE SEPARATOR' (U+2028)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.4.1
    • Component/s: Response Writers
    • Labels:
      None

      Description

      The Unicode Character 'LINE SEPARATOR' (U+2028) is not escaped in json response, resulting in a exception when evaluting this response on a client (in our case a firefox 3.0.19 , chrome 5.0.375.55 beta) webbrowser.

      Evaluting a response with this U+2028 char results in a 'unterminated string literal' error in firefox.

      1. patch-SOLR-1936.txt
        0.9 kB
        Robert Hofstra
      2. patch-SOLR-1936-test.txt
        0.8 kB
        Robert Hofstra
      3. patch-SOLR-1936-TRUNK.patch
        1.0 kB
        Robert Hofstra
      4. SOLR-1936.patch
        0.9 kB
        Yonik Seeley

        Activity

        Hide
        Robert Hofstra added a comment -

        patch for JSONResponseWriter 1.4.0

        Including test

        Show
        Robert Hofstra added a comment - patch for JSONResponseWriter 1.4.0 Including test
        Hide
        Robert Hofstra added a comment -

        patch for current trunk version ( 01-06-2010)

        Show
        Robert Hofstra added a comment - patch for current trunk version ( 01-06-2010)
        Hide
        Yonik Seeley added a comment -

        In the interest of not destroying information, we should probably not map U+2028 to "\n", but instead encode it as \u2028

        Show
        Yonik Seeley added a comment - In the interest of not destroying information, we should probably not map U+2028 to "\n", but instead encode it as \u2028
        Hide
        Robert Hofstra added a comment -

        You're right,
        I try it, should I provide a new patch?

        Show
        Robert Hofstra added a comment - You're right, I try it, should I provide a new patch?
        Hide
        Robert Hofstra added a comment -

        When mapping to \u2028

        ...
        case '\u2028': writer.write('
        '); writer.write('\u2028'); break;
        ...

        results also in a 'unterminated string literal' error in firefox.

        Show
        Robert Hofstra added a comment - When mapping to \u2028 ... case '\u2028': writer.write(' '); writer.write('\u2028'); break; ... results also in a 'unterminated string literal' error in firefox.
        Hide
        Yonik Seeley added a comment -

        Here's my version of the patch.
        Perhaps your issue as caused by writing out the actual \u2028 character (as opposed to a string starting with backslash, followed by 'u', etc...)

        Show
        Yonik Seeley added a comment - Here's my version of the patch. Perhaps your issue as caused by writing out the actual \u2028 character (as opposed to a string starting with backslash, followed by 'u', etc...)
        Hide
        Robert Hofstra added a comment -

        Tested SOLR-1936.patch and its working

        Show
        Robert Hofstra added a comment - Tested SOLR-1936 .patch and its working
        Hide
        Yonik Seeley added a comment -

        Committed to trunk. I'll backport to 3.1 and 1.4.1 shortly.

        Show
        Yonik Seeley added a comment - Committed to trunk. I'll backport to 3.1 and 1.4.1 shortly.

          People

          • Assignee:
            Unassigned
            Reporter:
            Robert Hofstra
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development