Pita/etherpad-lite — pull request #949 by unindented (2012-08-13 16:22:52+00:00)
Title: Normalize inserted text using UNorm

If you try pasting the character *ä* into a pad, it disconnects the client. If you paste the character *ä* instead, it doesn't.

For some reason, the client was sending the server a Unicode-normalized version of inserted strings. So if for example we inserted the string *ä* (i.e. `\x61\xCC\x88`) into the document, what would be sent to the server would be *ä* (i.e. `\xC3\xA4`).

This wouldn't be a problem on its own. BUT JavaScript reports that the length of the first string is 2, while the length of the second one is 1.

So the command that was being sent to the server was `Z:1>2*0+1$ä`, when it should really be `Z:1>1*0+1$ä`. When the `checkRep` method checks the length of the inserted string, it finds an inconsistency, and disconnects the client.

We now normalize the inserted string before the command is generated, so the length is always correct.

This pull request has @Pita's approval.