From 94379f0e2a3915bdf203154da7e0daf99c53bffc Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: May 18 2020 15:41:19 +0000 Subject: Add patch for rhbz#1836614 --- diff --git a/0001-problems-Handle-errors-when-fetching-titles.patch b/0001-problems-Handle-errors-when-fetching-titles.patch new file mode 100644 index 0000000..add166f --- /dev/null +++ b/0001-problems-Handle-errors-when-fetching-titles.patch @@ -0,0 +1,71 @@ +From 756addbc8e36fd7ce654ac4f0ea38ee34ae794e2 Mon Sep 17 00:00:00 2001 +From: Ernestas Kulik +Date: Mon, 18 May 2020 08:09:54 +0200 +Subject: [PATCH] problems: Handle errors when fetching titles + +Fallout from 837cb787caa4667a928673353e4ea8205ef9419a. + +If any of the URIs in reported_to are inaccessible, the resulting HTTP +error will become an exception, which is totally unnecessary, because +the user will most likely have no idea what to do. Handling the +exception gracefully will just keep the dummy title. + +This commit also narrows down the handled exceptions to GLib.Error, +since BeautifulSoup will eat whatever we feed it and not complain and +any other error should probably get some attention. + +https://bugzilla.redhat.com/show_bug.cgi?id=1836614 +--- + src/gnome_abrt/problems.py | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/src/gnome_abrt/problems.py b/src/gnome_abrt/problems.py +index 4e50b79..2854aa8 100644 +--- a/src/gnome_abrt/problems.py ++++ b/src/gnome_abrt/problems.py +@@ -18,7 +18,8 @@ + import datetime + import logging + import re +-from urllib import request ++import sys ++import urllib + + from bs4 import BeautifulSoup + +@@ -114,22 +115,25 @@ class Problem: + self._url_done = True + + def on_update_title(source_object, res, user_data): +- _, title = res.propagate_value() +- if title: +- self._title = title +- self._problem.source.notify(ProblemSource.CHANGED_PROBLEM, +- self._problem) ++ try: ++ _, title = res.propagate_value() ++ if title: ++ self._title = title ++ self._problem.source.notify(ProblemSource.CHANGED_PROBLEM, ++ self._problem) ++ except GLib.Error as error: ++ print(error.message, file=sys.stderr) + + task = Gio.Task.new(None, None, on_update_title, None) + + def update_title(task, source_object, task_data, cancellable): + try: +- html = request.urlopen(self._data).read().decode("UTF-8") ++ html = urllib.request.urlopen(self._data).read().decode("UTF-8") + soup = BeautifulSoup(html, "html.parser") + value = GObject.Value(str, soup.title.string) + + task.return_value(value) +- except Exception as ex: ++ except urllib.error.HTTPError as ex: + error = GLib.Error("Fetching title for problem report failed: %s" % (ex)) + task.return_error(error) + +-- +2.26.2 + diff --git a/gnome-abrt.spec b/gnome-abrt.spec index 0a62867..04f5c10 100644 --- a/gnome-abrt.spec +++ b/gnome-abrt.spec @@ -22,6 +22,8 @@ Source0: %{url}/archive/%{commit}.tar.gz#/%{name}-%{commit}.tar.gz Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz %endif +Patch0: 0001-problems-Handle-errors-when-fetching-titles.patch + BuildRequires: git-core BuildRequires: meson BuildRequires: gettext