Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-32

Result of select request is not well-formed XML when text field contains non-ASCII chars and ampersand

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0
    • Component/s: search
    • Labels:
    • Environment:

      Seen when running with the supplied Jetty container, macosx, JDK 1.5.0_06


      Starting with the supplied start.jar, the ampersand from this field is not correctly escaped in the XML search results provided by the select page:

      <?xml version="1.0" encoding="UTF-8"?>
      <field name="id">amp-test-one</field>
      <field name="content">Les événements chez Bonnie & Clyde.</field>

      The "content" field is defined as a "text" field in the schema.

      Adding this document to the index and querying on "id:amp-test-one" returns
      <str name="content">Les événements chez Bonnie & Clyde.& Clyde.</str>
      <str name="id">amp-test-one</str>

      With first "Bonnie & Clyde" unescaped and then the correct escaped &

      Browsing the index with Luke shows that the field is correctly stored.

      I think this might be a Jetty bug: patching the util/XML class of SOLR to avoid the use of Writer.write(String,start,len) fixes the problem. Maybe the Jetty ServletWriter gets confused by the presence of non-ascii chars?

      Here are my changes in util/XML.java. It looks like the class did use String.substring(...) before, Writer.write might be faster but it seems like it's broken in that environment.

      Here are my patches to util/XML.java:

      Index: src/java/org/apache/solr/util/XML.java
      — src/java/org/apache/solr/util/XML.java (revision 422655)
      +++ src/java/org/apache/solr/util/XML.java (working copy)
      @@ -159,8 +159,8 @@
      if (subst != null) {
      if (start<i)

      { - // out.write(str.substring(start,i)); - out.write(str, start, i-start); + out.write(str.substring(start,i)); + // out.write(str, start, i-start); // n+=i-start; }

      @@ -172,8 +172,8 @@
      // n += str.length();
      } else if (start<str.length())

      { - // out.write(str.substring(start)); - out.write(str, start, str.length()-start); + out.write(str.substring(start)); + // out.write(str, start, str.length()-start); // n += str.length()-start; }

      // return n;




            • Assignee:
              yseeley@gmail.com Yonik Seeley
              bdelacretaz Bertrand Delacretaz


              • Created:

                Issue deployment