diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2022-10-21 18:47:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 18:47:21 +0200 |
commit | e73ff0e961da2b57f4ff63185c0929cc222c7372 (patch) | |
tree | 425d588e9e5ac88243886ef6a201de42f074ec30 /core | |
parent | f77f7d4ba9373c090b03705c81024c7ef0c9a1f9 (diff) | |
parent | 56fa8f1d58efd62f941e9fd94f6c3e156a8b7a6b (diff) |
Merge pull request #67636 from groud/fix_localize_path
Fix localize_path with custom protocol identifiers
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 19 | ||||
-rw-r--r-- | core/string/ustring.cpp | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 001a351e0b..beef773699 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -153,8 +153,23 @@ const PackedStringArray ProjectSettings::_trim_to_supported_features(const Packe #endif // TOOLS_ENABLED String ProjectSettings::localize_path(const String &p_path) const { - if (resource_path.is_empty() || p_path.begins_with("res://") || p_path.begins_with("user://") || - (p_path.is_absolute_path() && !p_path.begins_with(resource_path))) { + if (resource_path.is_empty() || (p_path.is_absolute_path() && !p_path.begins_with(resource_path))) { + return p_path.simplify_path(); + } + + // Check if we have a special path (like res://) or a protocol identifier. + int p = p_path.find("://"); + bool found = false; + if (p > 0) { + found = true; + for (int i = 0; i < p; i++) { + if (!is_ascii_alphanumeric_char(p_path[i])) { + found = false; + break; + } + } + } + if (found) { return p_path.simplify_path(); } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 2e0ad94fcf..c86c8316fe 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3675,7 +3675,7 @@ String String::simplify_path() const { if (p > 0) { bool only_chars = true; for (int i = 0; i < p; i++) { - if (!is_ascii_char(s[i])) { + if (!is_ascii_alphanumeric_char(s[i])) { only_chars = false; break; } |