Author: rgodfrey
Date: Mon Jun 13 15:12:56 2016
New Revision: 1748254
URL: http://svn.apache.org/viewvc?rev=1748254&view=rev
Log:
QPID-7301 : Fix JMS selector grammar to ensure it fails when an invalid syntax
is used
Modified:
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/SelectorParserTest.java
qpid/java/trunk/common/src/main/grammar/SelectorParser.jj
qpid/java/trunk/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java
Modified:
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/SelectorParserTest.java
URL:
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/SelectorParserTest.java?rev=1748254&r1=1748253&r2=1748254&view=diff
==============================================================================
---
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/SelectorParserTest.java
(original)
+++
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/SelectorParserTest.java
Mon Jun 13 15:12:56 2016
@@ -49,6 +49,12 @@ public class SelectorParserTest extends
testPass("prop1 = prop2");
}
+ public void testPropertyInvalid()
+ {
+ testFail("prop1 = prop2 foo AND string = 'Test'");
+ }
+
+
public void testPropertyNames()
{
testPass("$min= TRUE AND _max= FALSE AND Prop_2 = true AND prop$3 =
false");
Modified: qpid/java/trunk/common/src/main/grammar/SelectorParser.jj
URL:
http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/grammar/SelectorParser.jj?rev=1748254&r1=1748253&r2=1748254&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/grammar/SelectorParser.jj (original)
+++ qpid/java/trunk/common/src/main/grammar/SelectorParser.jj Mon Jun 13
15:12:56 2016
@@ -188,7 +188,7 @@ BooleanExpression JmsSelector() :
}
{
(
- left = orExpression()
+ left = orExpression() <EOF>
)
{
return asBooleanExpression(left);
Modified:
qpid/java/trunk/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java
URL:
http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java?rev=1748254&r1=1748253&r2=1748254&view=diff
==============================================================================
---
qpid/java/trunk/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java
(original)
+++
qpid/java/trunk/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java
Mon Jun 13 15:12:56 2016
@@ -1,23 +1,23 @@
/* Generated By:JavaCC: Do not edit this line. SelectorParser.java */
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
*/
package org.apache.qpid.filter.selector;
@@ -35,15 +35,14 @@ import org.apache.qpid.filter.PropertyEx
import org.apache.qpid.filter.PropertyExpressionFactory;
import org.apache.qpid.filter.UnaryExpression;
-/**
- * JMS Selector Parser generated by JavaCC
- *
- * Do not edit this .java file directly - it is autogenerated from
SelectorParser.jj
+/**
+ * JMS Selector Parser generated by JavaCC
+ *
+ * Do not edit this .java file directly - it is autogenerated from
SelectorParser.jj
*/
public class SelectorParser<E> implements SelectorParserConstants {
private PropertyExpressionFactory<E> _factory;
-
public SelectorParser()
{
this(new StringReader(""));
@@ -75,12 +74,13 @@ public class SelectorParser<E> implement
throw new ParseException("Expression will not result in a boolean
value: " + value);
}
-// ----------------------------------------------------------------------------
-// Grammer
-// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// Grammer
+// ----------------------------------------------------------------------------
final public BooleanExpression JmsSelector() throws ParseException {
Expression left=null;
left = orExpression();
+ jj_consume_token(0);
{if (true) return asBooleanExpression(left);}
throw new Error("Missing return statement in function");
}
@@ -602,6 +602,38 @@ public class SelectorParser<E> implement
catch(LookaheadSuccess ls) { return true; }
}
+ private boolean jj_3R_12() {
+ if (jj_scan_token(36)) return true;
+ if (jj_3R_10()) return true;
+ return false;
+ }
+
+ private boolean jj_3R_55() {
+ if (jj_scan_token(IN)) return true;
+ if (jj_scan_token(33)) return true;
+ if (jj_3R_38()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_60()) { jj_scanpos = xsp; break; }
+ }
+ if (jj_scan_token(35)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_47() {
+ if (jj_scan_token(IS)) return true;
+ if (jj_scan_token(NOT)) return true;
+ if (jj_scan_token(NULL)) return true;
+ return false;
+ }
+
+ private boolean jj_3R_13() {
+ if (jj_scan_token(37)) return true;
+ if (jj_3R_10()) return true;
+ return false;
+ }
+
private boolean jj_3R_33() {
if (jj_scan_token(NULL)) return true;
return false;
@@ -1059,38 +1091,6 @@ public class SelectorParser<E> implement
if (jj_3R_10()) return true;
return false;
}
-
- private boolean jj_3R_12() {
- if (jj_scan_token(36)) return true;
- if (jj_3R_10()) return true;
- return false;
- }
-
- private boolean jj_3R_55() {
- if (jj_scan_token(IN)) return true;
- if (jj_scan_token(33)) return true;
- if (jj_3R_38()) return true;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_60()) { jj_scanpos = xsp; break; }
- }
- if (jj_scan_token(35)) return true;
- return false;
- }
-
- private boolean jj_3R_47() {
- if (jj_scan_token(IS)) return true;
- if (jj_scan_token(NOT)) return true;
- if (jj_scan_token(NULL)) return true;
- return false;
- }
-
- private boolean jj_3R_13() {
- if (jj_scan_token(37)) return true;
- if (jj_3R_10()) return true;
- return false;
- }
/** Generated Token Manager. */
public SelectorParserTokenManager token_source;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]