diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-04-19 17:04:48 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-04-19 17:15:43 +0800 |
commit | d8fed8fb695b585533edf81ab941d62c4e5caade (patch) | |
tree | a5cb54950f614c1570ef6761519dbf3c5b5fdbe6 /editor/plugins/animation_library_editor.cpp | |
parent | 1d2177938df078dae7be87665b7caf27c123cd38 (diff) | |
download | redot-engine-d8fed8fb695b585533edf81ab941d62c4e5caade.tar.gz |
Fix AnimationLibrary name validation
Diffstat (limited to 'editor/plugins/animation_library_editor.cpp')
-rw-r--r-- | editor/plugins/animation_library_editor.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index 2e9a82a7c2..581c3c05a5 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -55,17 +55,15 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) { ERR_FAIL_COND(al.is_null()); if (p_name == "") { error = TTR("Animation name can't be empty."); - - } else if (String(p_name).contains("/") || String(p_name).contains(":") || String(p_name).contains(",") || String(p_name).contains("[")) { + } else if (!AnimationLibrary::is_valid_name(p_name)) { error = TTR("Animation name contains invalid characters: '/', ':', ',' or '['."); } else if (al->has_animation(p_name)) { error = TTR("Animation with the same name already exists."); } - } else { if (p_name == "" && bool(player->call("has_animation_library", ""))) { error = TTR("Enter a library name."); - } else if (String(p_name).contains("/") || String(p_name).contains(":") || String(p_name).contains(",") || String(p_name).contains("[")) { + } else if (!AnimationLibrary::is_valid_name(p_name)) { error = TTR("Library name contains invalid characters: '/', ':', ',' or '['."); } else if (bool(player->call("has_animation_library", p_name))) { error = TTR("Library with the same name already exists."); @@ -258,7 +256,7 @@ void AnimationLibraryEditor::_load_file(String p_path) { } } - String name = p_path.get_file().get_basename(); + String name = AnimationLibrary::validate_name(p_path.get_file().get_basename()); int attempt = 1; |