From 7901f5d1dc1ead04438f59042ebbe05ade95578a Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Wed, 13 Jul 2016 11:16:39 +0500 Subject: [PATCH] Convert msg_body into unicode in preprocess. --- talon/quotations.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/talon/quotations.py b/talon/quotations.py index ae56cdd..d9dba21 100644 --- a/talon/quotations.py +++ b/talon/quotations.py @@ -280,10 +280,15 @@ def preprocess(msg_body, delimiter, content_type='text/plain'): Replaces link brackets so that they couldn't be taken for quotation marker. Splits line in two if splitter pattern preceded by some text on the same line (done only for 'On wrote:' pattern). + + Converts msg_body into a unicode. """ # normalize links i.e. replace '<', '>' wrapping the link with some symbols # so that '>' closing the link couldn't be mistakenly taken for quotation # marker. + if isinstance(msg_body, bytes): + msg_body = msg_body.decode('utf8') + def link_wrapper(link): newline_index = msg_body[:link.start()].rfind("\n") if msg_body[newline_index + 1] == ">":