From ae96797d333feaca4d8f76cb509ac3e3effb32b4 Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 2 Jun 2011 20:31:27 -0400 Subject: [PATCH] Fix bug #791805: RTF output does not handle { and } properly. --- src/calibre/ebooks/rtf/rtfml.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/ebooks/rtf/rtfml.py b/src/calibre/ebooks/rtf/rtfml.py index f3febb1743..60f69e2e17 100644 --- a/src/calibre/ebooks/rtf/rtfml.py +++ b/src/calibre/ebooks/rtf/rtfml.py @@ -68,8 +68,13 @@ TODO: ''' def txt2rtf(text): + # Escape { and } in the text. + text = text.replace('{', r'\'7b') + text = text.replace('}', r'\'7d') + if not isinstance(text, unicode): return text + buf = cStringIO.StringIO() for x in text: val = ord(x)