mmb/weechat-otr — pull request #43 by tribut (2013-11-21 21:46:38+00:00)
Title: Properly sanitize PRIVMSG commands

This PR will
- add the sanitize() function we talked about in https://github.com/mmb/weechat-otr/pull/39#issuecomment-28987587 for arguments to PRIVMSG
- split commands using `\r\n` as required by the protocol spec
- use `.splitlines()` instead of `.split(\n)` to split multi-line messages

The latter is due to the fact that there is no guarantee how a client will encode linebreaks inside the encrypted message (I'm not sure about what guarantees potr makes in terms of how messages it `inject()`s look like, but it's not harmful anyway).
Note that `sanitize()` implicitly assumes that encoded messages don't contain the ascii-byte used to encode the "bad" chars if the unicode-representations of those chars are removed from a message. This is generally not true, but for utf-8 it is - so I think this is a reasonable implementation.