You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/09/30 11:33:41 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12][IOTDB-1785] Fix Illegal String ending with . being parsed to PartialPath (#4064)

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

qiaojialin pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new f274407  [To rel/0.12][IOTDB-1785] Fix Illegal String ending with . being parsed to PartialPath (#4064)
f274407 is described below

commit f274407b5bcc22f60ca94f1ca8537ff4d3e5e402
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Thu Sep 30 19:33:17 2021 +0800

    [To rel/0.12][IOTDB-1785] Fix Illegal String ending with . being parsed to PartialPath (#4064)
---
 .../src/main/java/org/apache/iotdb/db/metadata/MetaUtils.java |  3 +++
 .../test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MetaUtils.java b/server/src/main/java/org/apache/iotdb/db/metadata/MetaUtils.java
index 7b9fe11..2d3e22a 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MetaUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MetaUtils.java
@@ -56,6 +56,9 @@ public class MetaUtils {
         }
         nodes.add(node);
         startIndex = i + 1;
+        if (startIndex == path.length()) {
+          throw new IllegalPathException(path);
+        }
       } else if (path.charAt(i) == '"') {
         int endIndex = path.indexOf('"', i + 1);
         // if a double quotes with escape character
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
index 49d85a2..376f765 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/MetaUtilsTest.java
@@ -28,6 +28,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
 
 public class MetaUtilsTest {
 
@@ -62,21 +63,31 @@ public class MetaUtilsTest {
 
     try {
       MetaUtils.splitPathToDetachedPath("root.sg.\"d.1\"\"s.1\"");
+      fail();
     } catch (IllegalPathException e) {
       Assert.assertEquals("root.sg.\"d.1\"\"s.1\" is not a legal path", e.getMessage());
     }
 
     try {
       MetaUtils.splitPathToDetachedPath("root..a");
+      fail();
     } catch (IllegalPathException e) {
       Assert.assertEquals("root..a is not a legal path", e.getMessage());
     }
 
     try {
       MetaUtils.splitPathToDetachedPath("root.sg.d1.'s1'");
+      fail();
     } catch (IllegalPathException e) {
       Assert.assertEquals("root.sg.d1.'s1' is not a legal path", e.getMessage());
     }
+
+    try {
+      MetaUtils.splitPathToDetachedPath("root.sg.d1.");
+      fail();
+    } catch (IllegalPathException e) {
+      Assert.assertEquals("root.sg.d1. is not a legal path", e.getMessage());
+    }
   }
 
   @Test