-
Notifications
You must be signed in to change notification settings - Fork 707
Add Unicode support for usernames - Allow international characters and emojis in usernames #2535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GhostTeen96
wants to merge
1
commit into
openfrontio:main
Choose a base branch
from
GhostTeen96:unicode-username-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address homoglyph security risk.
Unicode support introduces homoglyph attacks where visually identical characters from different scripts enable username impersonation. For example, Cyrillic 'а' (U+0430) looks identical to Latin 'a' (U+0061), allowing "Admin" and "Аdmin" to coexist as different usernames.
While
resolveConfusablesTransformer()handles this for profanity detection (line 16), it doesn't prevent duplicate-looking usernames during registration or display.Consider one of these approaches:
🧩 Analysis chain
🌐 Web query:
Unicode property escapes \p{L} \p{N} \p{Emoji} browser support Chrome Firefox Safari Edge 2024 2025💡 Result:
Short answer
Notes about \p{Emoji}
Practical guidance
Sources
Want a one-line compatibility table for specific Chrome/Firefox/Safari/Edge versions (2024–2025)? I can produce it.
Citations:
🏁 Script executed:
Repository: openfrontio/OpenFrontIO
Length of output: 190
Unicode property escapes have solid modern browser support, but transpilation may be needed for legacy support.
Unicode property escapes (
\p{L},\p{N}) are supported in all modern browsers—Chrome 64+, Firefox 78+, Safari 11.1+, and Edge 79+. However:regexpuvia Babel) to convert Unicode property escapes to equivalent character classes.\p{Emoji}is supported but has limitations for complex emoji (multi-codepoint sequences, ZWJ sequences). For reliable emoji detection, consider\p{Extended_Pictographic}or combineEmoji_Presentation/Emoji_Modifierproperties with sequence handling.Verify your project's target browsers in
tsconfig.json,.browserslistrc, orbabel.config.jsto determine if transpilation is required.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, this is a video game, where such issues are relatively unproblematic. To ensure protection against homoglyph attacks, simply standardise characters that look the same. For example, use the Latin letter “a” instead of the Cyrillic letter “a”. However, if a user enters a Cyrillic “a”, replace it with a Latin “a” in the background. Deal with all other problematic characters in the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 653
🌐 Web query:
💡 Result:
Short answer — obscenity supports confusable/unicode-homoglyph normalization as a transformer in its matching pipeline. Import the library exports (matchers, censor, datasets and the recommended transformers) and include the recommended transformers (which contain confusables normalization) when you build a matcher.
Example (CommonJS / ESM):
const { RegExpMatcher, TextCensor, englishDataset, englishRecommendedTransformers } = require('obscenity');
const matcher = new RegExpMatcher({ ...englishDataset.build(), ...englishRecommendedTransformers });
const censor = new TextCensor();
const matches = matcher.getAllMatches('ʃ𝐟ʃὗƈk ỹоứ'); // confusable/form-mangled text
console.log(censor.applyTo('ʃ𝐟ʃὗƈk ỹоứ', matches));
Sources:
References:
[1] obscenity (npm / GitHub) — package README and API examples.
[2] confusables (npm) — library for removing/injecting confusable characters.
🌐 Web query:
💡 Result:
Short answer — yes.
The npm package "confusables" (gc/confusables) normalizes/removes Unicode homoglyphs for English; API includes remove(...) and obfuscate(...). Example:
import remove from 'confusables'; remove('fück') // -> 'fuck'. [1]
Alternatives that use Unicode's confusables data:
Underlying standard: these libraries are based on Unicode's confusables mappings (UTS Public lobbies map will now be picked from a randomized playlist, assuring each map is played at least once, without duplicates. #39 / confusables.txt). For robust/security-sensitive use (IDNs, identifiers), follow UTS Public lobbies map will now be picked from a randomized playlist, assuring each map is played at least once, without duplicates. #39 guidance rather than ad-hoc rules. [4]
Sources:
[1] npm "confusables" (gc/confusables).
[2] npm "unicode-confusables" / @ensdomains.
[3] npm "homoglypher".
[4] Unicode Technical Standard UTS #39 (confusables.txt).
@Otzie2023, that's a pragmatic approach for the gaming context! Here's how to implement confusables normalization:
Recommended Implementation
Install the
confusablespackage, which normalizes visually similar Unicode characters to their Latin equivalents:Then update
src/core/validations/username.ts:This way, when a user enters "Аdmin" (with Cyrillic "а"), it gets normalized to "Admin" (Latin) in the background, preventing duplicate-looking usernames while still allowing genuine international names like "José" or "李明" to pass through.
🧬 Code Graph Analysis Results
<src/core/Util.ts> (lines 64-72)
<src/core/Util.ts> (lines 173-177)
<src/core/Util.ts> (lines 347-350)
🧠 Learnings used