Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-05-22 16:10:08 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-05-22 16:10:08 +0300
commitffa23a43c62b594fc7751cb85096d05085910b6b (patch)
treed49177988ebf644fd4c298999a2da1c0b79d4907
parent66e3c505e3f66485f3698691ffb9f77ba3e78a3a (diff)
update - URIComponent just for cookie value
-rw-r--r--web/assets/js/util/common.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index 20df4f4e..6dad047d 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -70,25 +70,27 @@ function debounce(fn, delay) {
function getCookie(cname) {
let name = cname + '=';
- let decodedCookie = decodeURIComponent(document.cookie);
- let ca = decodedCookie.split(';');
+ let ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
+ // decode cookie value only
+ return decodeURIComponent(c.substring(name.length, c.length));
}
}
return '';
}
+
function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
let expires = 'expires=' + d.toUTCString();
- document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/';
+ // encode cookie value
+ document.cookie = cname + '=' + encodeURIComponent(cvalue) + ';' + expires + ';path=/';
}
function usageColor(data, threshold, total) {