Show
Ignore:
Timestamp:
09.10.2006 13:20:00 (14 years ago)
Author:
mdewsnip
Message:

Now puts the terms through xmlSafe() as well, to prevent invalid XML with weird terms containing punctuation.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/indexers/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java

    r12999 r13054  
    225225        // something like this: 
    226226        // if (term.field().equals(TEXTFIELD)) 
    227         query_results_xml.append("  <Term value=\"" + term.text() + "\" field=\"" + term.field() + "\" freq=\"" + term_freq + "\" />\n"); 
     227        query_results_xml.append("  <Term value=\"" + xmlSafe(term.text()) + "\" field=\"" + term.field() + "\" freq=\"" + term_freq + "\" />\n"); 
    228228        } 
    229229 
     
    307307 
    308308    private static String xmlSafe(String text) { 
    309         return text.replaceAll("\\&", "\\&amp;"); 
    310     } 
     309    text = text.replaceAll("&","&amp;amp;"); 
     310    text = text.replaceAll("<","&amp;lt;"); 
     311    text = text.replaceAll(">","&amp;gt;"); 
     312    text = text.replaceAll("'","&amp;#039;"); 
     313    text = text.replaceAll("\\\"","&amp;quot;"); 
     314    return text; 
     315    } 
     316 
    311317 
    312318    private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, String fuzziness)