Changeset 13054
- Timestamp:
- 2006-10-09T13:20:00+13:00 (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/java/org/nzdl/gsdl/LuceneWrap/GS2LuceneQuery.java
r12999 r13054 225 225 // something like this: 226 226 // 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"); 228 228 } 229 229 … … 307 307 308 308 private static String xmlSafe(String text) { 309 return text.replaceAll("\\&", "\\&"); 310 } 309 text = text.replaceAll("&","&amp;"); 310 text = text.replaceAll("<","&lt;"); 311 text = text.replaceAll(">","&gt;"); 312 text = text.replaceAll("'","&#039;"); 313 text = text.replaceAll("\\\"","&quot;"); 314 return text; 315 } 316 311 317 312 318 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, String fuzziness) -
trunk/indexers/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java
r12999 r13054 225 225 // something like this: 226 226 // 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"); 228 228 } 229 229 … … 307 307 308 308 private static String xmlSafe(String text) { 309 return text.replaceAll("\\&", "\\&"); 310 } 309 text = text.replaceAll("&","&amp;"); 310 text = text.replaceAll("<","&lt;"); 311 text = text.replaceAll(">","&gt;"); 312 text = text.replaceAll("'","&#039;"); 313 text = text.replaceAll("\\\"","&quot;"); 314 return text; 315 } 316 311 317 312 318 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, String fuzziness)
Note:
See TracChangeset
for help on using the changeset viewer.