From d6c8b130411e3126426da58e2d8f10311a4edae2 Mon Sep 17 00:00:00 2001 From: John Garland Date: Wed, 5 May 2010 03:19:54 +1000 Subject: [PATCH] Handle trackers with incorrect / missing icon mimetypes --- deluge/ui/tracker_icons.py | 11 +++++++++-- tests/openbt.png | Bin 0 -> 673 bytes tests/test_tracker_icons.py | 14 +++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tests/openbt.png diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 5a6aa3b68..b079738f3 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -424,8 +424,15 @@ class FaviconParser(HTMLParser): href = value elif attr == "type": type = value - if href and type: - self.icons.append((href, type)) + if href: + try: + mimetype = extension_to_mimetype(href.rpartition('.')[2]) + except KeyError: + pass + else: + type = mimetype + if type: + self.icons.append((href, type)) def handle_endtag(self, tag): if tag == "head": diff --git a/tests/openbt.png b/tests/openbt.png new file mode 100644 index 0000000000000000000000000000000000000000..270d617aec02a1f51da388ad978afe47022a11d6 GIT binary patch literal 673 zcmV;S0$%-zP)L} zXWR!2*4JG$k{Q!}{*v~>`(;x5W{K+hBpJCvxY9XlU%x@_W0jqEhJU%!ojS_@aHb>-SfzW=34#>5fw z@4`4dV>Yx2YM09NuhG6$CjSmQXiBiyLT3{e@1k|_G6vsk2YTjyUSrGx?4=4sIu+z( z_!S__fhFLpk-rc_5Jp z`ywLXrlDRBp0PCq?kwGbb^pOo&fBbWEpF6k5doN>`}%DJ?0x(MZ_C7BV*`U~HOdDV zzpOt5%3cXFn?;N}%vpKLdf2ck%aHL{(7w&$Jd*QsTxNRD)W5fx$E2^&A|!w}{@mRdipyVIpnYCulNA5BlD+LV@-VQZP*Z z@