summaryrefslogtreecommitdiffstats
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-03-05 13:29:26 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-03-05 13:29:26 +0100
commitb2622218f9baf6d9aa1f447d0eb532226f27c0bb (patch)
tree66675fc5dcbcb9efc62085f3dbc53dc421254962 /modules/mono/csharp_script.cpp
parentfd6910a743701f6688219ab7a6f470b4f0fffcc1 (diff)
parentae8752a731ed0b1c9307bfc5ae817e917a887294 (diff)
downloadredot-engine-b2622218f9baf6d9aa1f447d0eb532226f27c0bb.tar.gz
Merge pull request #74330 from aleksrutins/csharp-identifier-validation
Ensure that C# script names (and therefore class names) are valid identifiers
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index d3c2415755..932e97c46b 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -58,6 +58,7 @@
#include "godotsharp_dirs.h"
#include "managed_callable.h"
#include "mono_gd/gd_mono_cache.h"
+#include "servers/text_server.h"
#include "signal_awaiter_utils.h"
#include "utils/macros.h"
#include "utils/naming_utils.h"
@@ -374,6 +375,10 @@ String CSharpLanguage::validate_path(const String &p_path) const {
if (keywords.find(class_name)) {
return RTR("Class name can't be a reserved keyword");
}
+ if (!TS->is_valid_identifier(class_name)) {
+ return RTR("Class name must be a valid identifier");
+ }
+
return "";
}