Skip to content

Commit d0cb8c4

Browse files
committed
Fix handling content of non-CPIM messages
1 parent b3fd7b4 commit d0cb8c4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sipsimple/streams/msrp/chat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,13 @@ def encode(self):
786786

787787
@classmethod
788788
def decode(cls, content, content_type):
789-
if not isinstance(content, bytes):
790-
raise TypeError("content should be an instance of bytes")
789+
if not isinstance(content, bytes) and not isinstance(content, str):
790+
raise TypeError("content should be an instance of bytes or string")
791791
type_helper = EmailParser().parsestr('Content-Type: {}'.format(content_type))
792792
content_type = type_helper.get_content_type()
793793
charset = type_helper.get_content_charset()
794+
if isinstance(content, str):
795+
content = content.encode(charset if charset else "ascii", "replace")
794796
return cls(content, content_type, charset)
795797

796798

0 commit comments

Comments
 (0)