You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/09/15 14:15:38 UTC
olingo-odata4 git commit: [OLINGO-659] Lexer recognizes invalid
charaters
Repository: olingo-odata4
Updated Branches:
refs/heads/master 9c3ca381e -> d84c3275c
[OLINGO-659] Lexer recognizes invalid charaters
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d84c3275
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d84c3275
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d84c3275
Branch: refs/heads/master
Commit: d84c3275cb732de2f652217eeea1d7310277e9c7
Parents: 9c3ca38
Author: Christia Holzer <c....@sap.com>
Authored: Tue Sep 15 12:57:31 2015 +0200
Committer: Christia Holzer <c....@sap.com>
Committed: Tue Sep 15 12:57:31 2015 +0200
----------------------------------------------------------------------
.../olingo/server/core/uri/antlr/UriLexer.g4 | 46 +++++++++++---------
.../core/uri/antlr/TestFullResourcePath.java | 21 ++++++++-
2 files changed, 46 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d84c3275/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
index 8092276..892accc 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
@@ -25,7 +25,7 @@ lexer grammar UriLexer;
//;==============================================================================
QM : '?' -> pushMode(MODE_QUERY); //first query parameter
AMP : '&' -> pushMode(MODE_QUERY); //more query parameters
-STRING : '\'' -> more, pushMode(MODE_STRING); //reads up to next single '
+STRING : '\'' -> more, pushMode(MODE_STRING) ; //reads up to next single '
QUOTATION_MARK : '\u0022' -> more, pushMode(MODE_JSON_STRING); //reads up to next unescaped "
SEARCH_INLINE : '$search' -> pushMode(MODE_SYSTEM_QUERY_SEARCH); //
FRAGMENT : '#' -> pushMode(MODE_FRAGMENT); //
@@ -311,7 +311,7 @@ mode MODE_FRAGMENT;
// character.
//;==============================================================================
-REST_F : ~('\r'|'\n')* -> type(REST), popMode;
+REST_F : ~('\r'|'\n')* -> type(REST), popMode;
//;==============================================================================
mode MODE_SYSTEM_QUERY_REST;
@@ -319,33 +319,35 @@ mode MODE_SYSTEM_QUERY_REST;
// character.
//;==============================================================================
-AMP_sqr : '&' -> type(AMP), popMode;
-FRAGMENT_sqr : '#' -> type(FRAGMENT), popMode;
+AMP_sqr : '&' -> type(AMP), popMode;
+FRAGMENT_sqr : '#' -> type(FRAGMENT), popMode;
-EQ_sqr : '=' -> type(EQ);
-REST : ~[&#=] ~[&#]*;
+EQ_sqr : '=' -> type(EQ);
+REST : ~[&#=] ~[&#]*;
+ERROR_CHARACTER_sqmr : .;
//;==============================================================================
mode MODE_SYSTEM_QUERY_SEARCH;
//;==============================================================================
-NOT_sqc : 'NOT' -> type(NOT);
-AND_sqc : 'AND' -> type(AND);
-OR_sqc : 'OR' -> type(OR);
-EQ_sqc : '=' -> type(EQ);
+NOT_sqc : 'NOT' -> type(NOT);
+AND_sqc : 'AND' -> type(AND);
+OR_sqc : 'OR' -> type(OR);
+EQ_sqc : '=' -> type(EQ);
-fragment WS_sqc : ( ' ' | '\u0009');
-WSP_sqc : WS_sqc+ -> type(WSP);
+fragment WS_sqc : ( ' ' | '\u0009');
+WSP_sqc : WS_sqc+ -> type(WSP);
-QUOTATION_MARK_sqc : '\u0022';
+QUOTATION_MARK_sqc : '\u0022';
-SEARCHWORD : ('a'..'z'|'A'..'Z')+;
-SEARCHPHRASE : QUOTATION_MARK_sqc ~["]* QUOTATION_MARK_sqc;
+SEARCHWORD : ('a'..'z'|'A'..'Z')+;
+SEARCHPHRASE : QUOTATION_MARK_sqc ~["]* QUOTATION_MARK_sqc;
// Follow Set
-CLOSE_qs : ')' -> popMode, type(CLOSE);
-SEMI_qs : ';' -> popMode, type(SEMI);
-AMP_qs : '&' -> popMode, type(AMP);
+CLOSE_qs : ')' -> popMode, type(CLOSE);
+SEMI_qs : ';' -> popMode, type(SEMI);
+AMP_qs : '&' -> popMode, type(AMP);
+ERROR_CHARACTER_sqms : .;
//;==============================================================================
mode MODE_STRING;
@@ -353,7 +355,8 @@ mode MODE_STRING;
// Any "'" characters inside a string are expressed as double "''".
//;==============================================================================
-STRING_s : ('\'\'' | ~[\u0027] )* '\'' -> type(STRING), popMode;
+STRING_s : ('\'\'' | ~[\u0027] )* '\'' -> type(STRING), popMode;
+ERROR_CHARACTER_sm : EOF | .;
//;==============================================================================
mode MODE_JSON_STRING;
@@ -361,7 +364,8 @@ mode MODE_JSON_STRING;
// Any """ characters inside a string are escaped with "\".
//;==============================================================================
-STRING_IN_JSON : ('\\"' | ~[\u0022] )* '"' -> popMode;
+STRING_IN_JSON : ('\\"' | ~[\u0022] )* '"' -> popMode;
+ERROR_CHARACTER_jsm : EOF | .;
//;==============================================================================
mode MODE_ODATA_GEO;
@@ -412,3 +416,5 @@ POLYGON : P_ O_ L_ Y_ G_ O_ N_ ;
SRID : S_ R_ I_ D_;
SQUOTE : '\'' -> popMode;
+
+ERROR_CHARACTER_g : .;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d84c3275/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index a723118..4cd015a 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1014,6 +1014,25 @@ public class TestFullResourcePath {
}
@Test
+ public void runResourcePathWithApostrophe() {
+ // TODO Currently "'" is not allowed in OData identifiers, but the specification allows this character (Unicode Cf)
+ testUri.runEx("ESAllPrim'").isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+ testUri.runEx("ESAllPrim'InvalidStuff").isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+
+ testUri.runEx("ESAllPrim", "$filter=PropertyInt16' eq 0")
+ .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+
+ testUri.runEx("ESAllPrim", "$filter=PropertyInt16 eq' 0")
+ .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+
+ testUri.runEx("ESAllPrim", "$filter=PropertyInt16 eq 0'")
+ .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+
+ testUri.runEx("ESAllPrim", "$filter=PropertyInt16 eq 'dsd''")
+ .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+ }
+
+ @Test
public void runEsNameCast() throws Exception {
testUri.run("ESTwoPrim/olingo.odata.test1.ETBase")
.isKind(UriInfoKind.resource).goPath()
@@ -5351,7 +5370,7 @@ public class TestFullResourcePath {
+ "(PropertyInt=1,PropertyString='2')")
.isExSemantic(MessageKeys.WRONG_NUMBER_OF_KEY_PROPERTIES);
}
-
+
@Test
public void startElementsInsteadOfNavigationProperties() {
testUri.runEx("ESAllPrim(0)/ESAllPrim(0)/ESAllPrim(0)").isExSemantic(MessageKeys.PROPERTY_NOT_IN_TYPE);