diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index 801bb2c92da6c..6b84618097e23 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -6,7 +6,7 @@ import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue' import debounce from 'lodash.debounce' import { IpcChannels } from '../../../constants' -import { openInternalPath } from '../../helpers/utils' +import { decodeHTML, openInternalPath } from '../../helpers/utils' import { clearLocalSearchSuggestionsSession, getLocalSearchSuggestions } from '../../helpers/api/local' import { invidiousAPICall } from '../../helpers/api/invidious' @@ -258,7 +258,7 @@ export default defineComponent({ } invidiousAPICall(searchPayload).then((results) => { - this.searchSuggestionsDataList = results.suggestions + this.searchSuggestionsDataList = results.suggestions.map(suggestion => decodeHTML(suggestion)) }).catch((err) => { console.error(err) if (process.env.IS_ELECTRON && this.backendFallback) { diff --git a/src/renderer/helpers/utils.js b/src/renderer/helpers/utils.js index 5f4d2c8201384..974af1743dfe6 100644 --- a/src/renderer/helpers/utils.js +++ b/src/renderer/helpers/utils.js @@ -664,6 +664,17 @@ export function escapeHTML(untrusted) { .replaceAll('\'', ''') } +/** + * Decode an html encoded string (for when we're not displaying something as html) + * @param {string} htmlEncodedString + * @returns {string} + */ +export function decodeHTML(htmlEncodedString) { + const testDiv = document.createElement('div') + testDiv.innerHTML = htmlEncodedString + return testDiv.innerText +} + /** * Performs a deep copy of a javascript object * @param {Object} obj