Skip to content

Commit

Permalink
Fix: Clean player names of unwanted chars (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushaway committed Nov 14, 2024
1 parent d1a0357 commit a6ba24d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web/configs/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"git": "1427",
"git": "1428",
"dev": true
}
12 changes: 11 additions & 1 deletion web/pages/page.banlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,17 @@ function setPostKey()
}

$data['ban_date'] = Config::time($res->fields['ban_created']);
$data['player'] = addslashes($res->fields['player_name']);

// Fix #1008 - bug: Player Names Contain Unwanted Non-Standard Characters
$raw_name = $res->fields['player_name'];
$cleaned_name = mb_convert_encoding($raw_name, 'UTF-8', 'UTF-8');
$unwanted_sequences = ["\xF3\xA0\x80\xA1"];
foreach ($unwanted_sequences as $sequence) {
$cleaned_name = str_replace($sequence, '', $cleaned_name);
}
$cleaned_name = trim($cleaned_name);

$data['player'] = addslashes($cleaned_name);
$data['type'] = $res->fields['type'];
$data['steamid'] = $res->fields['authid'];
// Fix #900 - Bad SteamID Format broke the page view, so give them an null SteamID.
Expand Down
12 changes: 11 additions & 1 deletion web/pages/page.commslist.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,17 @@ function setPostKey()
}

$data['ban_date'] = Config::time($res->fields['ban_created']);
$data['player'] = addslashes($res->fields['player_name']);

// Fix #1008 - bug: Player Names Contain Unwanted Non-Standard Characters
$raw_name = $res->fields['player_name'];
$cleaned_name = mb_convert_encoding($raw_name, 'UTF-8', 'UTF-8');
$unwanted_sequences = ["\xF3\xA0\x80\xA1"];
foreach ($unwanted_sequences as $sequence) {
$cleaned_name = str_replace($sequence, '', $cleaned_name);
}
$cleaned_name = trim($cleaned_name);

$data['player'] = addslashes($cleaned_name);
$data['steamid'] = $res->fields['authid'];
// Fix #906 - Bad SteamID Format broke the page view, so give them an null SteamID.
if (!\SteamID\SteamID::isValidID($data['steamid'])) {
Expand Down

0 comments on commit a6ba24d

Please sign in to comment.