improved token validation (#4747)

This commit is contained in:
gabryon99 2020-11-19 10:33:45 +01:00
parent 197726a4a9
commit 26e0c5cd10

View file

@ -1154,10 +1154,14 @@ end
function validateToken(token)
if (not token) then return false end
if (string.len(token) ~= 32) then
traceError(TRACE_ERROR, TRACE_CONSOLE, "The token lenght must be of 32 characters!")
return false
end
if (string.len(token) ~= 32) then return false end
-- iterate over each byte of the string
for b in token:gmatch("%x%x") do
-- if the byte is not valid then return false
if (tonumber(b, 16) == nil) then
return false
end
end
return true
end