jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r531165 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java
Date Sun, 22 Apr 2007 11:42:36 GMT
Author: mreutegg
Date: Sun Apr 22 04:42:35 2007
New Revision: 531165

URL: http://svn.apache.org/viewvc?view=rev&rev=531165
Log:
JCR-859: rep:excerpt() may return malformed XML

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java?view=diff&rev=531165&r1=531164&r2=531165
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultHighlighter.java
Sun Apr 22 04:42:35 2007
@@ -28,6 +28,7 @@
 import org.apache.lucene.index.TermVectorOffsetInfo;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
+import org.apache.jackrabbit.util.Text;
 
 /**
  * This is an adapted version of the <code>FulltextHighlighter</code> posted
in
@@ -212,7 +213,8 @@
                     if (skippedChars > surround) {
                         skippedChars = surround;
                     }
-                    sb.append(cbuf, 0, surround - skippedChars);
+                    sb.append(Text.encodeIllegalXMLCharacters(
+                            new String(cbuf, 0, surround - skippedChars)));
                     sb.append(END_FRAGMENT_SEPARATOR);
                 }
             }
@@ -239,7 +241,8 @@
                 }
             }
 
-            sb.append(cbuf, skippedChars, cbuf.length - skippedChars);
+            sb.append(Text.encodeIllegalXMLCharacters(
+                    new String(cbuf, skippedChars, cbuf.length - skippedChars)));
 
             // iterate terms
             for (Iterator iter = fi.iterator(); iter.hasNext();) {
@@ -283,7 +286,8 @@
                 } else {
                     skippedChars = 0;
                 }
-                sb.append(cbuf, 0, EOF ? skip : (surround - skippedChars));
+                sb.append(Text.encodeIllegalXMLCharacters(
+                        new String(cbuf, 0, EOF ? skip : (surround - skippedChars))));
                 sb.append(END_FRAGMENT_SEPARATOR);
             }
         }



Mime
View raw message