You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Prevent creating any type of file with a leading dot
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: gotnospirit <gotnospirit@gmail.com>
This commit is contained in:
@@ -51,13 +51,20 @@ String DirectoryCreateDialog::_validate_path(const String &p_path) const {
|
||||
return TTR("Folder name cannot be empty.");
|
||||
}
|
||||
|
||||
if (p_path.contains("\\") || p_path.contains(":") || p_path.contains("*") ||
|
||||
p_path.contains("|") || p_path.contains(">")) {
|
||||
return TTR("Folder name contains invalid characters.");
|
||||
}
|
||||
|
||||
for (const String &part : p_path.split("/")) {
|
||||
if (part.is_empty()) {
|
||||
return TTR("Folder name cannot be empty.");
|
||||
}
|
||||
if (p_path.contains("\\") || p_path.contains(":") || p_path.contains("*") ||
|
||||
p_path.contains("|") || p_path.contains(">") || p_path.ends_with(".") || p_path.ends_with(" ")) {
|
||||
return TTR("Folder name contains invalid characters.");
|
||||
if (part.ends_with(" ") || part[0] == ' ') {
|
||||
return TTR("Folder name cannot begin or end with a space.");
|
||||
}
|
||||
if (part[0] == '.') {
|
||||
return TTR("Folder name cannot begin with a dot.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user