This is an automated email from the ASF dual-hosted git repository. justinchen pushed a commit to branch object-name-fix in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 677ea256f934912eee44df2df8533b98914b83b3 Author: Caideyipi <[email protected]> AuthorDate: Mon Jan 5 17:04:15 2026 +0800 windows --- .../apache/iotdb/commons/schema/table/TsTable.java | 12 ++++--- .../apache/iotdb/commons/utils/WindowsOSUtils.java | 37 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TsTable.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TsTable.java index 8f5f5f44f60..f19d2f58d07 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TsTable.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TsTable.java @@ -30,6 +30,7 @@ import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory; import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema; import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchemaUtil; import org.apache.iotdb.commons.utils.CommonDateTimeUtils; +import org.apache.iotdb.commons.utils.WindowsOSUtils; import org.apache.iotdb.rpc.TSStatusCode; import com.google.common.collect.ImmutableList; @@ -435,11 +436,12 @@ public class TsTable { } } - public static boolean isInvalid4ObjectType(final String column) { - return column.equals(".") - || column.equals("..") - || column.contains("./") - || column.contains(".\\"); + public static boolean isInvalid4ObjectType(final String path) { + return path.equals(".") + || path.equals("..") + || path.contains("./") + || path.contains(".\\") + || !WindowsOSUtils.isLegalPathSegment4Windows(path); } public static String getObjectStringError(final String columnType, final String columnName) { diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java index 60cc5a938b0..f4fb375c23b 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java @@ -19,6 +19,41 @@ package org.apache.iotdb.commons.utils; +import org.apache.tsfile.external.commons.lang3.SystemUtils; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + public class WindowsOSUtils { - + private static final String ILLEGAL_WINDOWS_CHARS = "\\/:*?\"<>|"; + private static final Set<String> ILLEGAL_WINDOWS_NAMES = + new HashSet<>(Arrays.asList("CON", "PRN", "AUX", "NUL", "COM1-COM9, LPT1-LPT9")); + + static { + for (int i = 0; i < 10; ++i) { + ILLEGAL_WINDOWS_NAMES.add("COM" + i); + ILLEGAL_WINDOWS_NAMES.add("LPT" + i); + } + } + + public static boolean isLegalPathSegment4Windows(final String pathSegment) { + if (!SystemUtils.IS_OS_WINDOWS) { + return true; + } + for (final char illegalChar : ILLEGAL_WINDOWS_CHARS.toCharArray()) { + if (pathSegment.indexOf(illegalChar) != -1) { + return false; + } + } + if (pathSegment.endsWith(".") || pathSegment.endsWith(" ")) { + return false; + } + for (final String illegalName : ILLEGAL_WINDOWS_NAMES) { + if (pathSegment.equalsIgnoreCase(illegalName)) { + return false; + } + } + return true; + } }
