jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Brown <benjamin.br...@thisisnumero.com>
Subject RE: Double String escaping - is it needed?
Date Tue, 10 Aug 2010 15:56:36 GMT
Following on...

My (possibly mis)understanding is that Text.escapeIllegalXpathSearchChars(String s) is incomplete
and should be covering all the characters in http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters

Since escapeIllegalXpathSearchChars "[is a] method you should use for calls to jcr:contains(...)"
and currently does NOT actually contain escaping for XPath's invalid single quote ('') - I
believe the intention of the method was mainly just to prevent Lucene issues.

Thus am I correct in that really all that needs to be done it to replace the existing escapeIllegalXpathSearchChars

public static String escapeIllegalXpathSearchChars(String s) {

      // Escape Lucene special chars & XPath illegal chars
	s = org.apache.lucene.queryParser.QueryParser.escape(s);	
      // Escape XPath illegal single quotes
      return s.replaceAll("'", "''");


I think this would prevent both XPath and Lucene issues as the name of the method suggests
(for as long as the Lucene special characters are also illegal XPath characters) or do I actually
need to escape twice, once for jcr's xpath, once for lucene as per my last posting....?


View raw message