From 7b5496e06c4e09d06684bbc4c779b19563551743 Mon Sep 17 00:00:00 2001 From: SuperBFG7 Date: Thu, 24 Jun 2021 10:16:21 +0200 Subject: [PATCH] fix handling of special characters in paths --- htdocs/js/mpd.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index 18b5e38..b6d80d0 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -103,7 +103,7 @@ var app = $.sammy(function () { full_path = full_path + chunk; $('#breadcrump').append( - '
  • ' + chunk + '
  • ' + '
  • ' + chunk + '
  • ' ); full_path += '/'; }); @@ -441,9 +441,12 @@ function webSocketConnect() { if (current_app !== 'browse' && current_app !== 'search') break; - /* The use of encodeURI() below might seem useless, but it's not. It prevents + /* The use of encodeURIComponent() below might seem useless, but it's not. It prevents * some browsers, such as Safari, from changing the normalization form of the * URI from NFD to NFC, breaking our link with MPD. + * + * encodeURIComponent() instead of encodeURI() is used to ensure special characters + * (like e.g. +) are handled correctly. */ if ($('#salamisandwich > tbody').is(':ui-sortable')) { $('#salamisandwich > tbody').sortable('destroy'); @@ -468,7 +471,7 @@ function webSocketConnect() { } $('#salamisandwich > tbody').append( '' + @@ -486,7 +489,7 @@ function webSocketConnect() { } $('#salamisandwich > tbody').append( '' + @@ -517,7 +520,7 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( '' + '' + '' + @@ -571,7 +574,7 @@ function webSocketConnect() { socket.send( onClickAction + ',' + - decodeURI( + decodeURIComponent( $(this).parents('tr').attr('uri') ) ); @@ -664,7 +667,7 @@ function webSocketConnect() { case 'song': socket.send( 'MPD_API_ADD_TRACK,' + - decodeURI($(this).attr('uri')) + decodeURIComponent($(this).attr('uri')) ); $('.top-right') .notify({ @@ -683,7 +686,7 @@ function webSocketConnect() { case 'plist': socket.send( 'MPD_API_ADD_PLAYLIST,' + - decodeURI($(this).attr('uri')) + decodeURIComponent($(this).attr('uri')) ); $('.top-right') .notify({ -- 2.20.1