Conversation
This fix changes the character set of the database so that players with Emoji's in their name can be banned. Since the source engine can't parse Emoji's, the value for the player's emoji is random text in the sourcebans database. Sourcemod installer needs to be updated to use the following for database setup: Character Set: utf8mb4 Collation: utf8mb4_unicode_ci
|
You can just remove emojis from nickname before inserting to query. char[] GetFixNamePlayer(int iClient)
{
char sName[MAX_NAME_LENGTH * 2 + 1];
GetClientName(iClient, sName, sizeof(sName));
for(int i = 0, len = strlen(sName), CharBytes; i < len;)
{
if((CharBytes = GetCharBytes(sName[i])) == 4)
{
len -= 4;
for(int u = i; u <= len; u++)
{
sName[u] = sName[u+4];
}
}
else i += CharBytes;
}
return sName;
} |
|
utf8mb4 charset would require sourcemod 1.10 with updated mysql version. |
|
Is there a reason to have 2 PRs? |
|
It's the first time i ever did a PR on Github. I thought a PR was needed for each edit (since different files are edited). @CrazyHackGUT I wish i'd known about that weeks ago when i asked for help in the sbpp discord server. No one had any (working) solutions (including Fishy!) for the emoji issue. @CrazyHackGUT One potential problem with that code is if the user's name is all emoji. |
|
I don't recall giving a solution at all? If I was even home at the time.
It's not the first time this issue is brought up, there was another issue
with Korean language, which mb4 didn't resolve.
…On Tue, Aug 28, 2018 at 02:06 Ruok2bu ***@***.***> wrote:
It's the first time i ever did a PR on Github. I thought a PR was needed
for each edit (since different files are edited). @CrazyHackGUT
<https://github.com/CrazyHackGUT> I wish i'd known about that weeks ago
when i asked for help in the sbpp discord server. No one had any (working)
solutions (including Fishy!) for the emoji issue.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#506 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGo0aqxZ7LY0MKYIbaEYrK8ZJbLm8pqGks5uVN3PgaJpZM4WM3eJ>
.
|
|
@Ruok2bu it's simple to resolve. if (szUsername[0] == 0) // nickname is empty
strcopy(szUsername, sizeof(szUsername), "unnamed"); // copy to username string "unnamed" |
This fix changes the character set of the database so that players with Emoji's in their name can be banned. Since the source engine can't parse Emoji's, the value for the player's emoji is random text in the sourcebans database.
Description
Replaces all instances of utf8 with utf8mb4
Motivation and Context
Players with emoji in name could not be banned (because default character set configured by installer does not take into account the 4 bytes needed for emoji).
How Has This Been Tested?
I installed the plugin change on 10 servers.
Types of changes
Checklist: