fix(es_extended/shared): return false instead of raising on invalid utf8

ESX.IsValidLocaleString only checks that the argument is a string, but a Lua
string is a byte array and need not be valid utf8. utf8.codes raises on a
malformed sequence rather than stopping, so the function throws where its
annotation promises a boolean.

esx_identity feeds raw client input into it through checkNameFormat, so a
modified client sending a lone 0xFF byte as a first name aborts the
registerIdentity callback before cb() runs. The client is left waiting on a
promise that never resolves and cannot get past the identity screen, and it
can be repeated at will.

utf8.len returns nil instead of raising, so it is enough to reject the string
up front.

Verified on artifact 25770: "Jo\255hn" used to raise "invalid UTF-8 code" and
now returns false. "John" still returns true, "Jo!hn" still returns false, and
"Jo3hn" with allowDigits still returns true.
This commit is contained in:
Selt
2026-07-27 05:09:24 +02:00
parent ca597cf6f4
commit d264553490
+4
View File
@@ -186,6 +186,10 @@ function ESX.IsValidLocaleString(str, allowDigits)
return false
end
if not utf8.len(str) then
return false
end
local locale = string.lower(Config.Locale)
local defaultRanges ={