Skip to content

Type issue leading to NotOTRMessage exception when it should have been UnencryptedError on python 3 #47

Description

@mathieui

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions