electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 8f4c384aad8531d1acecffde5583deefc251fc50
parent b1d23896562d0311b3bbcb56588a67f99d76047c
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat, 18 Apr 2020 05:48:11 +0200

qt crash reporter: html.escape traceback to avoid formatting issues

fixes #6099

Diffstat:
Melectrum/base_crash_reporter.py | 5++++-
Melectrum/gui/qt/exception_window.py | 10++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/electrum/base_crash_reporter.py b/electrum/base_crash_reporter.py @@ -121,9 +121,12 @@ class BaseCrashReporter(Logger): ['git', 'describe', '--always', '--dirty'], cwd=dir) return str(version, "utf8").strip() + def _get_traceback_str(self) -> str: + return "".join(traceback.format_exception(*self.exc_args)) + def get_report_string(self): info = self.get_additional_info() - info["traceback"] = "".join(traceback.format_exception(*self.exc_args)) + info["traceback"] = self._get_traceback_str() return self.issue_template.format(**info) def get_user_description(self): diff --git a/electrum/gui/qt/exception_window.py b/electrum/gui/qt/exception_window.py @@ -22,6 +22,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import sys +import html from PyQt5.QtCore import QObject import PyQt5.QtCore as QtCore @@ -58,8 +59,6 @@ class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger): main_box.addWidget(QLabel(BaseCrashReporter.REQUEST_HELP_MESSAGE)) collapse_info = QPushButton(_("Show report contents")) - # FIXME if traceback contains special HTML characters, e.g. '<' - # then formatting issues arise (due to rich_text=True) collapse_info.clicked.connect( lambda: self.msg_box(QMessageBox.NoIcon, self, _("Report contents"), self.get_report_string(), @@ -139,6 +138,13 @@ class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger): def get_wallet_type(self): return self.main_window.wallet.wallet_type + def _get_traceback_str(self) -> str: + # The msg_box that shows the report uses rich_text=True, so + # if traceback contains special HTML characters, e.g. '<', + # they need to be escaped to avoid formatting issues. + traceback_str = super()._get_traceback_str() + return html.escape(traceback_str) + def _show_window(*args): if not Exception_Window._active_window: