From e59d0037f1388c757e05ba6969f4541968ca2671 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Dec 2010 11:25:08 -0700 Subject: [PATCH] Comments editor: Strip HTML comments from markup --- src/calibre/gui2/comments_editor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index ddff830911..3886fd81f1 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -62,6 +62,8 @@ class EditorWidget(QWebView): # {{{ def __init__(self, parent=None): QWebView.__init__(self, parent) + self.comments_pat = re.compile(r'', re.DOTALL) + for wac, name, icon, text, checkable in [ ('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True), ('ToggleItalic', 'italic', 'format-text-italic', _('Italic'), @@ -213,6 +215,7 @@ class EditorWidget(QWebView): # {{{ raw = unicode(self.page().mainFrame().toHtml()) raw = xml_to_unicode(raw, strip_encoding_pats=True, resolve_entities=True)[0] + raw = self.comments_pat.sub('', raw) try: root = html.fromstring(raw)