[F] UpsertUserAll Crash with usernames longer than 8 chars
Build AquaMai / build (push) Has been cancelled Details

pull/84/head
Clansty 2024-11-14 22:58:20 +08:00
parent 705b6cc03d
commit 6c5791b1fe
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
1 changed files with 9 additions and 2 deletions

View File

@ -52,8 +52,15 @@ class UpsertUserAllHandler(
if (!userName.isValidUsername()) if (!userName.isValidUsername())
{ {
// Maybe it's encoded // Maybe it's encoded
userName = String(userName.toByteArray(Charsets.ISO_8859_1), Charsets.UTF_8) val decodeUserName = String(userName.toByteArray(Charsets.ISO_8859_1), Charsets.UTF_8)
if (!userName.isValidUsername()) 400 - "Invalid username" if (userName.isValidUsername()) {
userName = decodeUserName
} else {
logger.warn("Invalid username: $userName")
// Maybe it's from some self-made import tools or modified game
// So apply it if user not in database
userName = userData?.userName ?: userName
}
} }
}) })