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 zcmZQzU}Ruq5D);-3Je)63=Con3=A3!3=9Gc3=9ek5OD@55awoJ0AVN>C#4+t-bgv{ z{Z8e;_ve%Y-}~WIh$f*N_+CUg@cl$-@AtpN+~55NVM)(-{}ue-Z%__=ua2f1&Q%V4 z&!rOhzCh0R{S#@gcmI8hKK-wq`R#x6+;9I=TEG0)2>tM1((~O{<-qs7%7O1C;Tjnj z7?cCwdnpILzb@nR{=Y%=hyS}y{Q8d$p1%J3Keqn!e{qj@|CIyZzg7->p8zuhq*vbW z{eP|S5C5;;`}6-+A&EY-D`nXOKHUW?Va|7WiM{{QOTzyEqsAO0)&y@%@uvGt=q z{Qvs>-~VZAe*EXOefxjrx*z|)eEatw<*$SCQgR7nIgP_Na%v|G#X<&;S4afrArHfYOC;@h6bGL2-XYIqKK=*!vt;7e|AA$nz~LzE_3p89;QL(V!1tUmJ?OM@;CnWZ8adzhuR-R3 z!bRHq{ZFNU_kGHN?}gFT 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', }