mirror of
https://github.com/lancedb/lancedb.git
synced 2026-09-21 20:45:57 +00:00
fix: do not allow . and .. as table names (#4191)
Do not allow . and .. as table names. They are incompatible with the local filesystem, and confusing in cases where they are supported.
This commit is contained in:
@@ -89,6 +89,18 @@ pub fn validate_table_name(name: &str) -> Result<()> {
|
||||
reason: "Table names cannot be empty strings".to_string(),
|
||||
});
|
||||
}
|
||||
if name == "." {
|
||||
return Err(Error::InvalidTableName {
|
||||
name: name.to_string(),
|
||||
reason: "Table name cannot be a single dot.".to_string(),
|
||||
});
|
||||
}
|
||||
if name == ".." {
|
||||
return Err(Error::InvalidTableName {
|
||||
name: name.to_string(),
|
||||
reason: "Table name cannot be two dots.".to_string(),
|
||||
});
|
||||
}
|
||||
if !TABLE_NAME_REGEX.is_match(name) {
|
||||
return Err(Error::InvalidTableName {
|
||||
name: name.to_string(),
|
||||
@@ -804,8 +816,11 @@ mod tests {
|
||||
assert!(validate_table_name("_12345table").is_ok());
|
||||
assert!(validate_table_name("table.12345").is_ok());
|
||||
assert!(validate_table_name("table.._dot_..12345").is_ok());
|
||||
assert!(validate_table_name("...").is_ok());
|
||||
|
||||
assert!(validate_table_name("").is_err());
|
||||
assert!(validate_table_name(".").is_err());
|
||||
assert!(validate_table_name("..").is_err());
|
||||
assert!(validate_table_name("my_table!").is_err());
|
||||
assert!(validate_table_name("my/table").is_err());
|
||||
assert!(validate_table_name("my@table").is_err());
|
||||
|
||||
Reference in New Issue
Block a user