chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1816004 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src: main/antlr3/org/apache/chemistry/opencmis/server/support/query/ main/java/org/apache/chemistry/opencmis/server/support/query/ test/java...
Date Wed, 22 Nov 2017 07:10:52 GMT
Author: jens
Date: Wed Nov 22 07:10:52 2017
New Revision: 1816004

URL: http://svn.apache.org/viewvc?rev=1816004&view=rev
Log:
Fix a problem in query parser for statements with double quotes [CMIS-1051]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g?rev=1816004&r1=1816003&r2=1816004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
Wed Nov 22 07:10:52 2017
@@ -140,9 +140,9 @@ STRING_LIT
     :  QUOTE ( ESC | ~(BACKSL|QUOTE) )* QUOTE
 	;
 
-WS : ( ' ' | '\t' | '\r'? '\n' )* { $channel=HIDDEN; };
+WS : ( ' ' | '\t' | '\r'? '\n' )+ { $channel=HIDDEN; };
 
-TIME_LIT : TIMESTAMP WS STRING_LIT;
+TIME_LIT : TIMESTAMP WS? STRING_LIT;
 
 ID :
     ('a'..'z'|'A'..'Z'|'_')

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java?rev=1816004&r1=1816003&r2=1816004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
Wed Nov 22 07:10:52 2017
@@ -18,6 +18,10 @@
  */
 package org.apache.chemistry.opencmis.server.support.query;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.antlr.runtime.ANTLRInputStream;
 import org.antlr.runtime.ANTLRStringStream;
 import org.antlr.runtime.CharStream;
 import org.antlr.runtime.CommonTokenStream;
@@ -54,6 +58,8 @@ public class QueryUtilStrict extends Que
     @Override
     public CommonTree parseStatement() throws RecognitionException {
         CharStream input = new ANTLRStringStream(statement);
+//    		InputStream lexerInput = new ByteArrayInputStream(statement.getBytes());
+//        CharStream input = new ANTLRInputStream(lexerInput, "UTF-8");
         CmisQlStrictLexer lexer = new CmisQlStrictLexer(input);
         tokens = new CommonTokenStream(lexer);
         CmisQlStrictParser parser = new CmisQlStrictParser(tokens);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java?rev=1816004&r1=1816003&r2=1816004&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
Wed Nov 22 07:10:52 2017
@@ -341,6 +341,12 @@ public class TestParserStrict extends Ab
         testLexerFail("TIME_LIT", "TIMESTAMP 123");
     }
 
+    // "timestamp'123'" OK
+    @Test
+    public void testTIME_LIT4() throws Exception {
+        testLexerOk("TIME_LIT", "TIMESTAMP'123'");
+    }
+
     // ----- Parser tests -----
 
     // literal:
@@ -756,4 +762,9 @@ public class TestParserStrict extends Ab
         testParserOk("query", "SELECT * FROM cmis:document " + "WHERE cmis:name LIKE 'abc\\%'");
     }
 
+    @Test
+    public void queryDoubleQuotes() throws Exception {
+        testParserFail("query", "SELECT * FROM cmis:document WHERE cmis:name = \"a\"");
+    }
+
 }



Mime
View raw message