summaryrefslogtreecommitdiffstats
path: root/editor/directory_create_dialog.cpp
diff options
context:
space:
mode:
authorsekoia <sequoia.1009@gmail.com>2023-08-28 15:27:00 +0200
committersekoia <sequoia.1009@gmail.com>2023-09-07 22:13:02 +0200
commitbbeb2f98f553812e50645f35faf6cad157fbaa5a (patch)
tree5f78d8a903a46117183ead6411ffdb975eeb9408 /editor/directory_create_dialog.cpp
parent031f6deefb080d4d7634d8190334a7049f265146 (diff)
downloadredot-engine-bbeb2f98f553812e50645f35faf6cad157fbaa5a.tar.gz
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>
Diffstat (limited to 'editor/directory_create_dialog.cpp')
-rw-r--r--editor/directory_create_dialog.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/editor/directory_create_dialog.cpp b/editor/directory_create_dialog.cpp
index fed7cb82c9..0efd11a6c1 100644
--- a/editor/directory_create_dialog.cpp
+++ b/editor/directory_create_dialog.cpp
@@ -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.");
}
}