jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1207025 - in /jackrabbit/trunk: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java
Date Mon, 28 Nov 2011 09:07:00 GMT
Author: mreutegg
Date: Mon Nov 28 09:06:59 2011
New Revision: 1207025

URL: http://svn.apache.org/viewvc?rev=1207025&view=rev
Log:
JCR-3157: Relax handling of apostrophe in GQL

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java?rev=1207025&r1=1207024&r2=1207025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/GQLTest.java
Mon Nov 28 09:06:59 2011
@@ -139,6 +139,18 @@ public class GQLTest extends AbstractQue
         checkResultWithRetries(stmt, "jcr:content", new Node[]{file1});
     }
 
+    /**
+     * Test for JCR-3157
+     */
+    public void testApostrophe() throws RepositoryException {
+        Node n1 = testRootNode.addNode("node1");
+        n1.setProperty("text", "let's go");
+        superuser.save();
+        String stmt = createStatement("\"let's go\"");
+        RowIterator rows = GQL.execute(stmt, superuser);
+        checkResult(rows, new Node[]{n1});
+    }
+
     public void testExcludeTerm() throws RepositoryException {
         Node n1 = testRootNode.addNode("node1");
         n1.setProperty("text", "foo");

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java?rev=1207025&r1=1207024&r2=1207025&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java
Mon Nov 28 09:06:59 2011
@@ -712,7 +712,6 @@ public final class GQL {
                         value.append(c);
                         break;
                     }
-                case '\'':
                 case '~':
                 case '^':
                 case '[':
@@ -961,11 +960,13 @@ public final class GQL {
                 }
             }
             buffer.append(", '");
+            // properly escape apostrophe. See JCR-3157
+            String escapedValue = value.replaceAll("'", "\\\\''");
             if (value.indexOf(' ') != -1) {
                 // phrase
-                buffer.append('"').append(value).append('"');
+                buffer.append('"').append(escapedValue).append('"');
             } else {
-                buffer.append(value);
+                buffer.append(escapedValue);
             }
             buffer.append("')");
             if (prohibited) {



Mime
View raw message