1
0
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:
sekoia
2023-08-28 15:27:00 +02:00
parent 031f6deefb
commit bbeb2f98f5
4 changed files with 19 additions and 4 deletions

View File

@@ -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.");
}
}