From 2c0637e2a515d8f302e0f783171835608717c8ad Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 28 May 2023 21:44:43 +0200 Subject: escape html for search results --- web/client.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'web') diff --git a/web/client.html b/web/client.html index 15d42ca..0f94c45 100644 --- a/web/client.html +++ b/web/client.html @@ -83,6 +83,12 @@ return song.title } + function newSourceLabel(song) { + const sourceLabel = document.createElement("SMALL"); + sourceLabel.appendChild(document.createTextNode(" (" + song.source + ")")); + return sourceLabel; + } + function renderPlaylist() { playlist = document.getElementById("playlist"); playlist.innerHTML = ""; @@ -139,9 +145,7 @@ listItem.appendChild(downvoteBtn); listItem.appendChild(document.createTextNode(song.weight + ' ' + formatSong(song))); - const sourceLabel = document.createElement("SMALL"); - sourceLabel.innerHTML = " (" + song.source + ")"; - listItem.appendChild(sourceLabel); + listItem.appendChild(newSourceLabel(song)); playlist.appendChild(listItem); } } @@ -295,7 +299,8 @@ }); listItem.classList.add("searchResult") - listItem.innerHTML = formatSong(song) + " (" + song.source + ")"; + listItem.appendChild(document.createTextNode(formatSong(song))); + listItem.appendChild(newSourceLabel(song)); searchResults.appendChild(listItem); } -- cgit v1.2.3