Skip to content

Commit

Permalink
tweak: improved invisible characters detection on player names
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Apr 6, 2024
1 parent 3bda913 commit e310dd7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion shared/cleanPlayerName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
export default (original: string) => {
// \u0000-\u001F > C0 controls
// \u007F-\u009F > delete + C1 controls
// \u1CBB\u1CBC > invisible characters
// \u200B-\u200D\uFEFF > zero width spaces
// \u200E > RTL mark
// \uA9C1-\uA9C5 > javanese text adornation (oversized)
// \u239B-\u23AD > Miscellaneous Technical — Bracket pieces items (oversized)
let displayName = original
.substring(0, 75) //lua should have truncated it first, but double checking
.replace(/[\u0000-\u001F\u007F-\u009F\u200B-\u200D\uFEFF\u200E\uA9C1-\uA9C5\u239B-\u23AD]/g, '')
.replace(/[\u0000-\u001F\u007F-\u009F\u1CBB\u1CBC\u200B-\u200D\uFEFF\u200E\uA9C1-\uA9C5\u239B-\u23AD]/g, '')
.replace(/~(HUD_\S+|HC_\S+|[a-z]|[a1]_\d+|bold|italic|ws|wanted_star|nrt|EX_R\*|BLIP_\S+|ACCEPT|CANCEL|PAD_\S+|INPUT_\S+|INPUTGROUP_\S+)~/ig, '') // https://docs.fivem.net/docs/game-references/text-formatting/
.replace(/\^\d/ig, '') //console color codes
.replace(/\p{Mark}{2,}/ug, '') //2+ consecutive marks (zalgo text)
Expand Down

0 comments on commit e310dd7

Please sign in to comment.