From de0226ba47910c97104a00edb9d5b23db8dcccbc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 25 Jan 2014 19:07:25 +0530 Subject: [PATCH] RTF Output: Fix failure to convert documents that contain comments with the -- string inside the comment. Fixes #1272588 [Private bug](https://bugs.launchpad.net/calibre/+bug/1272588) --- src/calibre/ebooks/rtf/rtfml.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/rtf/rtfml.py b/src/calibre/ebooks/rtf/rtfml.py index 40a2490fed..53d0c6ea07 100644 --- a/src/calibre/ebooks/rtf/rtfml.py +++ b/src/calibre/ebooks/rtf/rtfml.py @@ -114,7 +114,9 @@ class RTFMLizer(object): output += '{\\page }' for item in self.oeb_book.spine: self.log.debug('Converting %s to RTF markup...' % item.href) - content = unicode(etree.tostring(item.data, encoding=unicode)) + # Removing comments is needed as comments with -- inside them can + # cause fromstring() to fail + content = re.sub(ur'', u'', etree.tostring(item.data, encoding=unicode), flags=re.DOTALL) content = self.remove_newlines(content) content = self.remove_tabs(content) content = etree.fromstring(content)