summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-03-23 11:29:26 +0100
committerGitHub <noreply@github.com>2018-03-23 11:29:26 +0100
commit1d0783018214d53ea830988bed6fc1a2ed9eb2d3 (patch)
tree83b580d19a5b51e46d717eb5de4706251da570f8
parentf16652d1a2f94432becea6a8d393a4f99d62fb7b (diff)
parentda6c07698f591b3eac773770dc776bf095c3d9ef (diff)
Merge pull request #17490 from robfram/homogenize-check-prop-names
Fix non-valid characters for `input_action`
-rw-r--r--editor/project_settings_editor.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 8080a04a67..75523cd843 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -123,6 +123,15 @@ void ProjectSettingsEditor::_notification(int p_what) {
}
}
+static bool _validate_action_name(const String &p_name) {
+ const CharType *cstr = p_name.c_str();
+ for (int i = 0; cstr[i]; i++)
+ if (cstr[i] == '/' || cstr[i] == ':' || cstr[i] == '"' ||
+ cstr[i] == '=' || cstr[i] == '\\' || cstr[i] < 32)
+ return false;
+ return true;
+}
+
void ProjectSettingsEditor::_action_selected() {
TreeItem *ti = input_editor->get_selected();
@@ -145,12 +154,12 @@ void ProjectSettingsEditor::_action_edited() {
if (new_name == old_name)
return;
- if (new_name.find("/") != -1 || new_name.find(":") != -1 || new_name.find("\"") != -1 || new_name == "") {
+ if (new_name == "" || !_validate_action_name(new_name)) {
ti->set_text(0, old_name);
add_at = "input/" + old_name;
- message->set_text(TTR("Invalid action (anything goes but '/', ':' or '\"')."));
+ message->set_text(TTR("Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or '\"'"));
message->popup_centered(Size2(300, 100) * EDSCALE);
return;
}
@@ -838,9 +847,9 @@ void ProjectSettingsEditor::_action_check(String p_action) {
action_add->set_disabled(true);
} else {
- if (p_action.find("/") != -1 || p_action.find(":") != -1 || p_action.find("\"") != -1) {
+ if (!_validate_action_name(p_action)) {
- action_add_error->set_text(TTR("Can't contain '/', ':' or '\"'"));
+ action_add_error->set_text(TTR("Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or '\"'"));
action_add_error->show();
action_add->set_disabled(true);
return;