Skip to content
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

Impossible to login as a guest with non-Latin characters #145

Open
Maxilver opened this issue Jul 1, 2020 · 2 comments
Open

Impossible to login as a guest with non-Latin characters #145

Maxilver opened this issue Jul 1, 2020 · 2 comments

Comments

@Maxilver
Copy link

Maxilver commented Jul 1, 2020

Hi!

Unfortunatelly it's impossible to enter as a guest with non-Latin name (cyrillic, chinese, etc). Seems do_guest_login() in embed.js treat these characters as not valid. Is it possible to replace the White-List regular expression new RegExp(/^[a-z\d\-_\s]+$/i) check with the Black-List regex check with forbidden special chars?

Thanks!

@EndenDragon
Copy link
Member

At this moment we are using alphanumeric expression as the only valid option for guest usernames as we are unsure what the appropriate non-latin characters will Discord accept. However I will keep this issue open as it is our eventual goal to include majority characters.

@oplik0
Copy link

oplik0 commented Aug 22, 2020

From their support page I believe most characters that aren't zero-width and non-rendering should work, at least if the guest usernames aren't subject to different rules than normal ones (and from my testing even some obscure characters that aren't in use since 15th century or don't render properly for me work. I haven't found a single non-working character yet. Even zwsp worked, so not even all zero-width characters are excluded).

Luckily, when using u flag in JS you can specify a unicode property selecting just letters: \p{L} will match any letter from any language, but not punctuation, control characters, symbols, separators or control characters. (and \P will do the opposite - exclude a property)
here is a nice list of character categories (there are also one letter short versions that group some of them in JS, but you can guess them from the categories on that list - just look at their first letter).

I think /^\P{C}+$/iu (or /^[\p{L}\p{N}\p{P}\p{S}\p{Z}\p{M}]+$/iu) should work fine, excluding only the most problematic control characters. /^[\P{C}\P{Zl}\P{Zp}]+$/iu will also exclude line break and paragraph separator (I checked and they're legal in usernames, but I don't know how Titan would handle them :V). Or if you want something more explicit (or just prefer a whitelist to a blacklist), it's equivalent to whitelisting /^[\p{L}\p{N}\p{P}\p{S}\p{Zs}\p{M}]+$/iu.

Also, a funny note for testing - discord actually appears to have a front end problems with guest usernames using weird unicode - with some characters you'll get an error when trying to create a guest account with them, but after reloading the page "open in browser" will take you to the web app with the username that you used. So Discord can handle them, but their dialog box for inputting usernames seems to have some problems :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants