Open
Description
On python 3:
In context.py, the basestring type is an alias to str; however, everything in and out of the library is bytes (otherwise it does not work), so when receiving a plaintext message during an encrypted session it never enters the test for unencryptedmessage and raises a nototrmessage (which does not provoke a warning because it is supposed to be raised only outside an OTR session).
Specifically, at the end of receiveMessage, message is a bytes object and basestring is “str”.
if isinstance(message, basestring):
if self.state != STATE_PLAINTEXT or \
self.getPolicy('REQUIRE_ENCRYPTION'):
raise UnencryptedMessage(message)
raise NotOTRMessage(messageData)
The fix should be to change,
basestring = str
to
basestring = bytes
at the beginning of potr/context.py, it seems to work fine.