mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:32:21 +00:00
[Security] Added username sanitization on server (#299)
Fixing issues #282 where players can bypass max username length by editing their storage. I added a sanitization on the server side to avoid all kind of cheat on the username as we can't trust clients
This commit is contained in:
@@ -44,6 +44,7 @@ import { andFN, manhattanDistFN, TileRef } from "./GameMap";
|
||||
import { AttackImpl } from "./AttackImpl";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
import { consolex } from "../Consolex";
|
||||
import { sanitizeUsername } from "../validations/username";
|
||||
|
||||
interface Target {
|
||||
tick: Tick;
|
||||
@@ -101,7 +102,7 @@ export class PlayerImpl implements Player {
|
||||
startTroops: number,
|
||||
) {
|
||||
this._flag = playerInfo.flag;
|
||||
this._name = playerInfo.name;
|
||||
this._name = sanitizeUsername(playerInfo.name);
|
||||
this._targetTroopRatio = 95n;
|
||||
this._troops = toInt(startTroops);
|
||||
this._workers = 0n;
|
||||
|
||||
Reference in New Issue
Block a user