summaryrefslogtreecommitdiff
path: root/modules/text_server_adv
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2023-01-23 19:00:44 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2023-01-23 20:50:30 +0200
commit458f720ea94ce1e5122635665d3b1a596167931a (patch)
treec09b8a44be5461fa9b03d14b5cb275da0e3eaf27 /modules/text_server_adv
parente6bd9c10fcc3acb8fe47b1c5c4b3e189143f4d33 (diff)
[TextServer] Add fallback code in case of missing ICU data.
Diffstat (limited to 'modules/text_server_adv')
-rw-r--r--modules/text_server_adv/text_server_adv.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index ddafae5e58..8d72ba12f6 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -6114,6 +6114,11 @@ String TextServerAdvanced::_percent_sign(const String &p_language) const {
}
int64_t TextServerAdvanced::_is_confusable(const String &p_string, const PackedStringArray &p_dict) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return -1;
+ }
+#endif
UErrorCode status = U_ZERO_ERROR;
int64_t match_index = -1;
@@ -6154,6 +6159,11 @@ int64_t TextServerAdvanced::_is_confusable(const String &p_string, const PackedS
}
bool TextServerAdvanced::_spoof_check(const String &p_string) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return false;
+ }
+#endif
UErrorCode status = U_ZERO_ERROR;
Char16String utf16 = p_string.utf16();
@@ -6176,6 +6186,11 @@ bool TextServerAdvanced::_spoof_check(const String &p_string) const {
}
String TextServerAdvanced::_strip_diacritics(const String &p_string) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return TextServer::strip_diacritics(p_string);
+ }
+#endif
UErrorCode err = U_ZERO_ERROR;
// Get NFKD normalizer singleton.
@@ -6213,6 +6228,12 @@ String TextServerAdvanced::_strip_diacritics(const String &p_string) const {
}
String TextServerAdvanced::_string_to_upper(const String &p_string, const String &p_language) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return p_string.to_upper();
+ }
+#endif
+
if (p_string.is_empty()) {
return p_string;
}
@@ -6235,6 +6256,12 @@ String TextServerAdvanced::_string_to_upper(const String &p_string, const String
}
String TextServerAdvanced::_string_to_lower(const String &p_string, const String &p_language) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return p_string.to_lower();
+ }
+#endif
+
if (p_string.is_empty()) {
return p_string;
}
@@ -6270,8 +6297,8 @@ PackedInt32Array TextServerAdvanced::_string_get_word_breaks(const String &p_str
breaks.insert(pos);
}
}
+ ubrk_close(bi);
}
- ubrk_close(bi);
PackedInt32Array ret;
@@ -6352,6 +6379,13 @@ PackedInt32Array TextServerAdvanced::_string_get_word_breaks(const String &p_str
}
bool TextServerAdvanced::_is_valid_identifier(const String &p_string) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ WARN_PRINT_ONCE("ICU data is not loaded, Unicode security and spoofing detection disabled.");
+ return TextServer::is_valid_identifier(p_string);
+ }
+#endif
+
enum UAX31SequenceStatus {
SEQ_NOT_STARTED,
SEQ_STARTED,