From: <die...@us...> - 2012-02-27 11:10:45
|
Revision: 3741 http://openutils.svn.sourceforge.net/openutils/?rev=3741&view=rev Author: diego_schivo Date: 2012-02-27 11:10:34 +0000 (Mon, 27 Feb 2012) Log Message: ----------- CRIT-48 Parentheses escape Modified Paths: -------------- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/FirstDigitEscapeTest.java Modified: trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java =================================================================== --- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2012-02-27 10:37:56 UTC (rev 3740) +++ trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2012-02-27 11:10:34 UTC (rev 3741) @@ -155,21 +155,33 @@ else if (ch == '(') { // "(" is the beginning of an expression only when used with the element() function - // not really a clean check, actually... - if (encodedPath.indexOf("element") > 0) + if (StringUtils.endsWith(StringUtils.substring(path, i), "element")) { inXpathCondition++; xpathWithFunction = true; } + else + { + encodedPath.append("_x0028_"); + continue; + } } else if (inXpathCondition > 0 && ch == ']') { inXpathCondition--; } - else if (inXpathCondition > 0 && xpathWithFunction && ch == ')') + else if (ch == ')') { - inXpathCondition--; - xpathWithFunction = false; + if (inXpathCondition > 0 && xpathWithFunction) + { + inXpathCondition--; + xpathWithFunction = false; + } + else + { + encodedPath.append("_x0029_"); + continue; + } } encodedPath.append(ch); } Modified: trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/FirstDigitEscapeTest.java =================================================================== --- trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/FirstDigitEscapeTest.java 2012-02-27 10:37:56 UTC (rev 3740) +++ trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/FirstDigitEscapeTest.java 2012-02-27 11:10:34 UTC (rev 3741) @@ -90,7 +90,7 @@ public void testEscapeParentheses() throws Exception { Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(ContentRepository.WEBSITE); - criteria.setBasePath("//myproject/Sport/F1/0a67369b-8cc6-43d8-b2d3-(c07b12a2ed5f)"); + criteria.setBasePath("/myproject/Sport/F1/0a67369b-8cc6-43d8-b2d3-(c07b12a2ed5f)"); criteria.add(Restrictions.eq("@jcr:primaryType", "mgnl:contentNode")); criteria.addOrder(Order.desc("@jcr:created")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |