From 8f07d854eb677f5f1376e90090d3e51bbcfddd5d Mon Sep 17 00:00:00 2001 From: YOMAN1792 <94007829+YOMAN1792@users.noreply.github.com> Date: Wed, 7 May 2025 12:23:25 -0400 Subject: [PATCH] refactor(main.lua): use ESX.IsValidLocaleString with configurable character sets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced the manual character validation logic in checkNameFormat with ESX.IsValidLocaleString to centralize string validation and allow configuration of valid character sets per locale. Added support for Config.ValidCharacterSets to enable or disable specific Unicode blocks such as Greek, Cyrillic, Hebrew, Arabic, or CJK (Chinese, Japanese, Korean). This change introduces greater flexibility for multilingual servers while maintaining basic Latin character support by default. ⚠️ Behavior changes: Characters that were previously allowed may now be rejected depending on the server’s locale configuration. --- [core]/esx_identity/server/main.lua | 31 +---------------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/[core]/esx_identity/server/main.lua b/[core]/esx_identity/server/main.lua index 5dcc4d7a..9ee283da 100644 --- a/[core]/esx_identity/server/main.lua +++ b/[core]/esx_identity/server/main.lua @@ -84,37 +84,8 @@ local function formatDate(str) return date end -local function checkValidCharacter(str) - for _, code in utf8.codes(str) do - if not ( - - (code >= 0x0041 and code <= 0x005A) or -- Basic Latin uppercase - (code >= 0x0061 and code <= 0x007A) or -- Basic Latin lowercase - (code == 0x0020 or code == 0x002D) or -- Space or dash - (code >= 0x00C0 and code <= 0x02AF) or -- Latin Extended - (code >= 0x0370 and code <= 0x03FF) or -- Greek - (code >= 0x0400 and code <= 0x04FF) or -- Cyrillic - (code >= 0x05D0 and code <= 0x05EA) or -- Hebrew letters - ( -- Arabic - (code >= 0x0620 and code <= 0x063F) or - (code >= 0x0641 and code <= 0x064A) or - (code >= 0x066E and code <= 0x066F) or - (code >= 0x0671 and code <= 0x06D3) or - (code == 0x06D5) or - (code >= 0x0750 and code <= 0x077F) or - (code >= 0x08A0 and code <= 0x08BD) - ) or - (code >= 0x4E00 and code <= 0x9FFF) -- CJK - ) - then - return false - end - end - return true -end - local function checkNameFormat(name) - if checkValidCharacter(name) then + if ESX.IsValidLocaleString(name) then local stringLength = string.len(name) return stringLength > 0 and stringLength < Config.MaxNameLength end