This is an automated email from the ASF dual-hosted git repository.

archanarai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git


The following commit(s) were added to refs/heads/master by this push:
     new 7284619  [OLINGO-1322]ODATA V2.0: An empty string validation in 
UriParser
7284619 is described below

commit 7284619af7cdc55d0d1b01505bc27f7df600f4b8
Author: Archana Rai <archana....@sap.com>
AuthorDate: Thu Dec 13 14:08:06 2018 +0530

    [OLINGO-1322]ODATA V2.0: An empty string validation in UriParser
---
 .../java/org/apache/olingo/odata2/core/uri/UriParserImpl.java |  4 ++++
 .../java/org/apache/olingo/odata2/core/uri/UriParserTest.java | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git 
a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/UriParserImpl.java
 
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/UriParserImpl.java
index 8373df7..3a31ad7 100644
--- 
a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/UriParserImpl.java
+++ 
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/UriParserImpl.java
@@ -468,6 +468,10 @@ public class UriParserImpl extends UriParser {
           throw new 
UriSyntaxException(UriSyntaxException.MISSINGKEYPREDICATENAME.addContent(key));
         }
       }
+      
+      if("''".equals(value) || value==null){
+        throw new 
UriSyntaxException(UriSyntaxException.INVALIDVALUE.addContent(value));
+      }
 
       EdmProperty keyProperty = null;
       for (final EdmProperty testKeyProperty : keyProperties) {
diff --git 
a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/UriParserTest.java
 
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/UriParserTest.java
index f08012a..51a2669 100644
--- 
a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/UriParserTest.java
+++ 
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/UriParserTest.java
@@ -254,6 +254,17 @@ public class UriParserTest extends BaseTest {
     assertEquals("1", result.getKeyPredicates().get(0).getLiteral());
     assertEquals("EmployeeId", 
result.getKeyPredicates().get(0).getProperty().getName());
   }
+  
+  @Test
+  public void parseEmployeesEntityWithEmptyKey() throws Exception {
+    parseWrongUri("/Employees('')", 
UriSyntaxException.INVALIDVALUE.addContent("''"));
+  }
+  
+  @Test
+  public void parseEmployeesEntityWithNullKey() throws Exception {
+    parseWrongUri("/Employees(null)", UriSyntaxException.INCOMPATIBLELITERAL);
+  }
+
 
   @Test
   public void parseEmployeesEntityWithKeyWithComma() throws Exception {

Reply via email to