From 5d808e006d902bd38e0449b1c6da849ef2ba528c Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Sun, 23 Feb 2020 04:30:57 +0100 Subject: [PATCH] webui: fix search encode in url hash. resolves #7265 (#7299) --- src/Jackett.Common/Content/custom.js | 15 ++++++++++++--- src/Jackett.Common/Content/index.html | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Jackett.Common/Content/custom.js b/src/Jackett.Common/Content/custom.js index 3ae00c6b7..2ee62d8b5 100644 --- a/src/Jackett.Common/Content/custom.js +++ b/src/Jackett.Common/Content/custom.js @@ -51,7 +51,12 @@ $(document).ready(function () { }); function openSearchIfNecessary() { - const hashArgs = location.hash.substring(1).split('&').reduce((prev, item) => Object.assign({ [item.split('=')[0]]: (item.split('=').length < 2 ? undefined : decodeURIComponent(item.split('=')[1])) }, prev), {}); + const hashArgs = location.hash.substring(1).split('&').reduce((prev, item) => + Object.assign({ + [item.split('=')[0]]: (item.split('=').length < 2 ? + undefined : + decodeURIComponent(item.split('=')[1].replace(/\+/g,'%20'))) + }, prev), {}); if ("search" in hashArgs) { showSearch(hashArgs.tracker, hashArgs.search, hashArgs.category); } @@ -775,7 +780,7 @@ function updateReleasesRow(row) } function showSearch(selectedIndexer, query, category) { - var selectedIndexers = [] + var selectedIndexers = []; if (selectedIndexer) selectedIndexers = selectedIndexer.split(","); $('#select-indexer-modal').remove(); @@ -842,7 +847,11 @@ function showSearch(selectedIndexer, query, category) { Tracker: releaseDialog.find('#searchTracker').val() }; - window.location.hash = $.param({ search: queryObj.Query, tracker: queryObj.Tracker.join(","), category: queryObj.Category.join(",") }); + window.location.hash = Object.entries({ + search: encodeURIComponent(queryObj.Query).replace(/%20/g,'+'), + tracker: queryObj.Tracker.join(","), + category: queryObj.Category.join(",") + }).map(([k, v], i) => k + '=' + v).join('&'); $('#jackett-search-perform').html($('#spinner').html()); $('#searchResults div.dataTables_filter input').val(""); diff --git a/src/Jackett.Common/Content/index.html b/src/Jackett.Common/Content/index.html index 84a18b327..1eb29c1a2 100644 --- a/src/Jackett.Common/Content/index.html +++ b/src/Jackett.Common/Content/index.html @@ -691,6 +691,6 @@ - +