Convert msg_body into unicode in preprocess.
This commit is contained in:
@@ -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.
|
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
|
Splits line in two if splitter pattern preceded by some text on the same
|
||||||
line (done only for 'On <date> <person> wrote:' pattern).
|
line (done only for 'On <date> <person> wrote:' pattern).
|
||||||
|
|
||||||
|
Converts msg_body into a unicode.
|
||||||
"""
|
"""
|
||||||
# normalize links i.e. replace '<', '>' wrapping the link with some symbols
|
# normalize links i.e. replace '<', '>' wrapping the link with some symbols
|
||||||
# so that '>' closing the link couldn't be mistakenly taken for quotation
|
# so that '>' closing the link couldn't be mistakenly taken for quotation
|
||||||
# marker.
|
# marker.
|
||||||
|
if isinstance(msg_body, bytes):
|
||||||
|
msg_body = msg_body.decode('utf8')
|
||||||
|
|
||||||
def link_wrapper(link):
|
def link_wrapper(link):
|
||||||
newline_index = msg_body[:link.start()].rfind("\n")
|
newline_index = msg_body[:link.start()].rfind("\n")
|
||||||
if msg_body[newline_index + 1] == ">":
|
if msg_body[newline_index + 1] == ">":
|
||||||
|
|||||||
Reference in New Issue
Block a user