From f3784723ae54b9394dd3db219457071ab9b48ecb Mon Sep 17 00:00:00 2001 From: DjLegolas Date: Wed, 29 Dec 2021 20:13:59 +0200 Subject: [PATCH] [UI] Add SVG support for tracker icons SVG files are supported by all browsers so need to support it as well, according to https://www.w3schools.com/html/html_favicon.asp Also, it appears as SEO.com site, which was dropped because of a cert issue, has only SVG icon. So enabled it again. Lastly, from python 3.2, `os.path.samefile` is supported on Windows. So Windows will now test TrackerIcons as well. --- .pre-commit-config.yaml | 1 + deluge/tests/data/seo.ico | Bin 1150 -> 0 bytes deluge/tests/data/seo.svg | 1 + deluge/tests/test_tracker_icons.py | 11 ++--------- deluge/ui/tracker_icons.py | 2 ++ 5 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 deluge/tests/data/seo.ico create mode 100644 deluge/tests/data/seo.svg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 133d536dd..8f00d42fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,7 @@ default_language_version: exclude: > (?x)^( deluge/ui/web/docs/template/.*| + deluge/tests/data/.*svg| )$ repos: - repo: https://github.com/ambv/black diff --git a/deluge/tests/data/seo.ico b/deluge/tests/data/seo.ico deleted file mode 100644 index 841e5287189481ae9c672f40f846d96faa7581dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcma)4T}TvR6dfr7i%2jmv!AsDMJg?Vf{3DsYIWCkD~*0I%b=p@$1n(@OzI_yga}MR zdg&pegkG{4LySzsx!J39o}vh5TC058dSZ|mCcHE8oqKW@5Z93PJfE z6|N?2fbnXFSGeDiSk@M&u${P zv{6I-VI6Niq)@nig|aw$J%UBMRgfDZjyX9*yTYrXwnfLt_Y5*w;C6o;n~sOE?ud>P z-6lrI8RTm1irC*Hnq2*2=Iwu#K$bM|K7X4Ee`mz@zKp(B?$z)yn8qK~!rDVRT;3_Y z{9ngdG;ZPH^8|{w{6+7J1k9KP@g4Y@5k49&8n%ay`%&<{$@iH*xZ_ONzH7M}!G=~H zM%1!>h_6qh8Fcl6ZE*EL9bt3I zzr2x31FB)!?^iZyaG#&>fA)@<=U-|meR=RKZr8q%-|5uvBzw=9Kqc!p#QKf>&Z4$i zlX;r-Pkn%ARQWZ$52TT`q<=ANYzw2F{cF2v;v4&y=lk#g3+M z=iMCP&`U`2NL|>sBCWUXA)XL#iMr`{nXQ1n0C+bGxKZ?f_(85{MEehA Cx+uZ` diff --git a/deluge/tests/data/seo.svg b/deluge/tests/data/seo.svg new file mode 100644 index 000000000..fc96f74d4 --- /dev/null +++ b/deluge/tests/data/seo.svg @@ -0,0 +1 @@ + seocom-target \ No newline at end of file diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index 8f6dda900..0f7a66c61 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -6,11 +6,9 @@ # import pytest -from twisted.trial.unittest import SkipTest import deluge.component as component import deluge.ui.tracker_icons -from deluge.common import windows_check from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons from . import common @@ -23,10 +21,6 @@ common.disable_new_release_check() @pytest.mark.internet class TrackerIconsTestCase(BaseTestCase): - - if windows_check(): - skip = 'cannot use os.path.samefile to compair on windows(unix only)' - def set_up(self): # Disable resizing with Pillow for consistency. self.patch(deluge.ui.tracker_icons, 'Image', None) @@ -60,10 +54,9 @@ class TrackerIconsTestCase(BaseTestCase): d.addCallback(self.assertEqual, icon) return d - def test_get_seo_ico_with_sni(self): + def test_get_seo_svg_with_sni(self): # seo using certificates with SNI support only - raise SkipTest('Site certificate expired') - icon = TrackerIcon(common.get_test_data_file('seo.ico')) + icon = TrackerIcon(common.get_test_data_file('seo.svg')) d = self.icons.fetch('www.seo.com') d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEqual, icon) diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 3f3ca4dbe..a1bcd78b5 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -609,11 +609,13 @@ MIME_MAP = { 'image/png': 'png', 'image/vnd.microsoft.icon': 'ico', 'image/x-icon': 'ico', + 'image/svg+xml': 'svg', 'gif': 'image/gif', 'jpg': 'image/jpeg', 'jpeg': 'image/jpeg', 'png': 'image/png', 'ico': 'image/vnd.microsoft.icon', + 'svg': 'image/svg+xml', }