TitanEmbeds / Titan

Create Discord server widgets for websites of all sizes! A simple to setup process for end-users. Server members may view or send messages into an embedded Discord channel.

Home Page:https://titanembeds.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Impossible to login as a guest with non-Latin characters

Maxilver opened this issue · comments

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!

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.

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