From beb3fa9a0e7c194777ee7d534fc44cea89ff8965 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Tue, 19 Mar 2024 18:00:54 -0700 Subject: [PATCH 1/3] escape ' in favorite titles --- HTML/Default/xmlbrowser.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HTML/Default/xmlbrowser.html b/HTML/Default/xmlbrowser.html index 10178e5b72..ad23c6afa5 100644 --- a/HTML/Default/xmlbrowser.html +++ b/HTML/Default/xmlbrowser.html @@ -169,7 +169,7 @@ [% IF item.type == 'audio' && item.url %] onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html | replace("'", "%27") %]');" [% ELSIF item.simpleAlbumLink && item.favorites_url %] onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.favorites_url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" [% ELSE %] @@ -181,7 +181,7 @@ [% IF item.type == 'audio' && item.url %] onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html | replace("'", "%27") %]');" [% ELSE %] onclick="Browse.XMLBrowser.toggleFavorite(this, '[% (item.index || index _ (start + loop.index)) | uri | replace("'", "%27") %]', '[% pageinfo.startitem %]', '[% sess %]');" [% END %] @@ -210,11 +210,11 @@ [%- BLOCK allcontrol -%] [% IF songinfo.favorites == 1 %] [% WRAPPER favaddlink noTarget=1 %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% END %] [% ELSIF songinfo.favorites == 2 %] [% WRAPPER favdellink noTarget=1 %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% END %] [% END %] From 8615b0385bb75f76549b3b95cee3c0b7362f3371 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Tue, 19 Mar 2024 20:58:28 -0700 Subject: [PATCH 2/3] fix favorites for Classic --- HTML/Default/xmlbrowser.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/HTML/Default/xmlbrowser.html b/HTML/Default/xmlbrowser.html index ad23c6afa5..15f74b98bb 100644 --- a/HTML/Default/xmlbrowser.html +++ b/HTML/Default/xmlbrowser.html @@ -164,12 +164,13 @@ [% END %] [% END %] + + + [% IF item.favorites == 1 %] [% WRAPPER favaddlink noTarget=1 %] - [% IF item.type == 'audio' && item.url %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" - [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html | replace("'", "%27") %]');" + [% IF songinfo.favorites && item.type != 'audio' %] + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% ELSIF item.simpleAlbumLink && item.favorites_url %] onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.favorites_url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" [% ELSE %] @@ -178,10 +179,8 @@ [% END %] [% ELSIF item.favorites == 2 %] [% WRAPPER favdellink noTarget=1 %] - [% IF item.type == 'audio' && item.url %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" - [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html | replace("'", "%27") %]');" + [% IF songinfo.favorites && item.type != 'audio' %] + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% ELSE %] onclick="Browse.XMLBrowser.toggleFavorite(this, '[% (item.index || index _ (start + loop.index)) | uri | replace("'", "%27") %]', '[% pageinfo.startitem %]', '[% sess %]');" [% END %] From acfae696ddd5afb2689ec61ab298faff3358dae4 Mon Sep 17 00:00:00 2001 From: Michael Herger Date: Wed, 20 Mar 2024 11:35:30 +0100 Subject: [PATCH 3/3] When we create a track-level favorite, we use the track's URL. In order to get the valid icon from the URL we (unfortunately) require a client object at this point. But in most cases we do have that, we only need to pass it around from within `Slim::Web::XMLBrowser`. Don't use the `favorite_url` on songinfo in the web UI, as that would refer to the album rather than the track. This is a slightly different approach at fixing #1007. --- Changelog8.html | 1 + HTML/Default/xmlbrowser.html | 19 +++++++++---------- Slim/Web/XMLBrowser.pm | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Changelog8.html b/Changelog8.html index 9c838965f6..e7e395ad02 100644 --- a/Changelog8.html +++ b/Changelog8.html @@ -23,6 +23,7 @@

Version 8.5.1

  • Bug Fixes:
    • +
    • Fix definition of track-level favorites' artwork.

    diff --git a/HTML/Default/xmlbrowser.html b/HTML/Default/xmlbrowser.html index 10178e5b72..15f74b98bb 100644 --- a/HTML/Default/xmlbrowser.html +++ b/HTML/Default/xmlbrowser.html @@ -164,12 +164,13 @@ [% END %] [% END %] + + + [% IF item.favorites == 1 %] [% WRAPPER favaddlink noTarget=1 %] - [% IF item.type == 'audio' && item.url %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" - [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html %]');" + [% IF songinfo.favorites && item.type != 'audio' %] + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% ELSIF item.simpleAlbumLink && item.favorites_url %] onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.favorites_url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" [% ELSE %] @@ -178,10 +179,8 @@ [% END %] [% ELSIF item.favorites == 2 %] [% WRAPPER favdellink noTarget=1 %] - [% IF item.type == 'audio' && item.url %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% item.url | uri | replace("'", "%27") %]', '[% (item.name _ " " _ stringBY _ " " _ item.artist) | uri | replace("'", "%27") %]');" - [% ELSIF songinfo.favorites %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.values.-1 | html %]');" + [% IF songinfo.favorites && item.type != 'audio' %] + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% ELSE %] onclick="Browse.XMLBrowser.toggleFavorite(this, '[% (item.index || index _ (start + loop.index)) | uri | replace("'", "%27") %]', '[% pageinfo.startitem %]', '[% sess %]');" [% END %] @@ -210,11 +209,11 @@ [%- BLOCK allcontrol -%] [% IF songinfo.favorites == 1 %] [% WRAPPER favaddlink noTarget=1 %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% END %] [% ELSIF songinfo.favorites == 2 %] [% WRAPPER favdellink noTarget=1 %] - onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html %]');" + onclick="SqueezeJS.Utils.toggleFavorite(this, '[% songinfo.favorites_url | uri | replace("'", "%27") %]', '[% crumb.name | html | replace("'", "%27") %]');" [% END %] [% END %] diff --git a/Slim/Web/XMLBrowser.pm b/Slim/Web/XMLBrowser.pm index 55943009cc..3028bff850 100644 --- a/Slim/Web/XMLBrowser.pm +++ b/Slim/Web/XMLBrowser.pm @@ -540,7 +540,7 @@ sub handleFeed { && !($subFeed->{type} && $subFeed->{type} eq 'search') && !(ref $subFeed->{'url'}) ) ) { - $subFeed->{'image'} ||= $subFeed->{'cover'} || $subFeed->{'icon'} || Slim::Player::ProtocolHandlers->iconForURL($subFeed->{'play'} || $subFeed->{'url'}); + $subFeed->{'image'} ||= $subFeed->{'cover'} || $subFeed->{'icon'} || Slim::Player::ProtocolHandlers->iconForURL($subFeed->{'play'} || $subFeed->{'url'}, $client); $subFeed->{'image'} = proxiedImage($subFeed->{'image'}); $stash->{'streaminfo'} = { @@ -999,9 +999,9 @@ sub handleFeed { my $type = $item->{'favorites_type'} || $item->{'type'} || 'link'; my $name = $item->{'favorites_title'} || $item->{'name'}; - my $icon = $item->{'favorites_icon'} || $item->{'image'} || $item->{'icon'} || Slim::Player::ProtocolHandlers->iconForURL($furl); + my $icon = $item->{'favorites_icon'} || $item->{'image'} || $item->{'icon'} || Slim::Player::ProtocolHandlers->iconForURL($furl, $client); - if ( ($item->{'play'} && !$item->{'favorites_type'}) + if ( ($item->{'play'} && !$item->{'favorites_type'}) || ($type eq 'playlist' && $furl =~ /^(file|db):/) ) { $type = 'audio';