From f0a925c38d75780fdfbe3c99f5aa75589168699a Mon Sep 17 00:00:00 2001 From: Matthias Rahlf Date: Thu, 13 Sep 2018 16:46:34 +0200 Subject: [PATCH] Escape part of a template string In ebook-edit, if a filename contains a '%' clicking 'Run check' results in an error: Traceback (most recent call last): File "/usr/lib/calibre/calibre/gui2/tweak_book/boss.py", line 72, in ans return func(*args, **kwargs) File "/usr/lib/calibre/calibre/gui2/tweak_book/boss.py", line 1249, in check_requested c.run_checks(current_container()) File "/usr/lib/calibre/calibre/gui2/tweak_book/check.py", line 221, in run_checks self.current_item_changed() File "/usr/lib/calibre/calibre/gui2/tweak_book/check.py", line 206, in current_item_changed template % (err.HELP, ifix, fix_tt, fix_msg, run_tt, run_msg)) ValueError: unsupported format character '_' (0x5f) at index 167 --- src/calibre/gui2/tweak_book/check.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/tweak_book/check.py b/src/calibre/gui2/tweak_book/check.py index be3009d3ac..2813731a57 100644 --- a/src/calibre/gui2/tweak_book/check.py +++ b/src/calibre/gui2/tweak_book/check.py @@ -195,10 +195,12 @@ class Check(QSplitter): activate = '
%s
' % ('
'.join(activate)) if many: activate += '
' + activate = activate.replace('%', '%%') template = header + ((msg + activate) if many else (activate + msg)) + footer else: activate = '
%s %s
' % ( open_tt, err.name, loc) + activate = activate.replace('%', '%%') template = header + activate + msg + footer self.help.setText( template % (err.HELP, ifix, fix_tt, fix_msg, run_tt, run_msg))