My bet there is that the client-side validation is counting octets, whereas the server, being Unicode-aware, is counting characters, and coming up with a different result.
Characters in that codeblock (and indeed all of U+1xxxx) are four-octets long in UTF-8. I don’t know what it’s counting, but Unicode 7/Unicode 8 issues (like amphora) could be in play.
Taking the string "
" as an example, javascript says
"😀".length = 2
and Ruby says
"😀".length = 1
Which is the correct implementation here? @codinghorror's blog post says:
because it’s nice and simple for users. So
is one character. That sounds reasonable to me.
However… the blog also says
This is indeed true of the Discourse password fields - one emoji = 2 characters. So if it’s showing as 2 characters in the password field, surely that should count as 2 characters in a password ![]()
On a related note, it is currently very difficult to type emojis directly into html password inputs - you can only copy/paste them in. This is the case on Chrome on mac (using system emoji window), and also Safari on iOS (the emoji button doesn’t even show up with the password field focused). So, as much as I try, I can’t use
as my password on Discourse (without cheating with copy/paste).
😀 is four octets in UTF-8: Base64 visualizer
I have no idea why Javascript gets that count. (UTF-16?) But 😀 does show as ⏺⏺ in the password field of Discourse (for me).
It would appear so (from here)
A sentence with spaces - could be the best personal password choice
I’m not sure a space would work. It’s a control character and there might be some filters somewhere that wouldn’t like it.
A space is absolutely fine, it’s just another character as far as a password is concerned. Try it here on meta - it works.
Rifacendo i test, ora che so che il mio gestore di password è
sicuro. La stessa cosa si verifica di nuovo: un numero sufficiente di emoji per ottenere un segno verde “ok” non è sufficiente per funzionare realmente. E mentre provavo password sempre più lunghe, in modo iterativo, sono stato disconnesso, credo al terzo tentativo. Quando sono riuscito finalmente a impostarla, con una password di
emoji, ho comunque visto lampeggiare il messaggio “sei stato disconnesso”, ma in realtà non sono stato disconnesso.
Non sono sicuro che questa disconnessione sia un bug specifico delle emoji o una sorta di funzione fuorviante (o almeno inutile). Se è una funzione, si prega di far sì che la casella “sei stato disconnesso” spieghi il motivo.
Sì, questo è dovuto all’eredità di JavaScript, che porta a un conteggio errato della lunghezza delle stringhe contenenti emoji (e altri caratteri del Piano Astrale). Il server conta la lunghezza correttamente.