mirror of
https://github.com/unraid/webgui.git
synced 2026-02-27 04:41:20 -06:00
clean up visibility cookies left in malformed state
This commit is contained in:
@@ -745,6 +745,28 @@ jQuery.prototype.mixedView = function(s) {
|
||||
});
|
||||
}
|
||||
}
|
||||
function sanitizeMultiCookie(cookieName, delimiter, removeDuplicates = false) {
|
||||
// Some browser states leave multi-value cookies with nulls, empties or duplicates.
|
||||
// This function cleans up any such cookies so that they do not break functionality.
|
||||
try {
|
||||
var uncleanCookie = $.cookie(cookieName);
|
||||
if (uncleanCookie) {
|
||||
uncleanCookie = uncleanCookie.split(delimiter);
|
||||
var cleanCookie = uncleanCookie.filter(n => n);
|
||||
if (removeDuplicates) { cleanCookie = [...new Set(cleanCookie)]; }
|
||||
if (JSON.stringify(uncleanCookie) !== JSON.stringify(cleanCookie)) {
|
||||
$.cookie(cookieName,cleanCookie.join(delimiter),{expires:3650});
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var ports = [<?=implode(',',array_map('escapestring',$ports))?>];
|
||||
var cpu = [];
|
||||
@@ -1175,6 +1197,7 @@ function addProperties() {
|
||||
}
|
||||
function showContent() {
|
||||
var count = {'db-box1':$('table#db-box1 tbody').length, 'db-box2':$('table#db-box2 tbody').length, 'db-box3':$('table#db-box3 tbody').length}
|
||||
sanitizeMultiCookie('inactive_content', ';', true);
|
||||
var inactive = $.cookie('inactive_content');
|
||||
if (inactive) {
|
||||
inactive = inactive.split(';');
|
||||
@@ -1186,6 +1209,7 @@ function showContent() {
|
||||
tbody.prev().hide();
|
||||
}
|
||||
}
|
||||
sanitizeMultiCookie('hidden_content', ';', true);
|
||||
var hidden = $.cookie('hidden_content');
|
||||
if (hidden) {
|
||||
hidden = hidden.split(';');
|
||||
|
||||
Reference in New Issue
Block a user