From 26bd909cf462821fb243d56d4d84fa99de94ac89 Mon Sep 17 00:00:00 2001 From: Tomasz Kontusz Date: Tue, 15 Oct 2024 19:46:07 +0200 Subject: [PATCH] Wrap timeZone in encodeURIComponent() This way timezones like Etc/GMT+3 will get sent correctly. Before this change the backend interpreted "Etc/GMT+3" as "Etc/GMT 3", which is not a valid timezone. --- tz_detect/static/tz_detect/js/tzdetect.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tz_detect/static/tz_detect/js/tzdetect.js b/tz_detect/static/tz_detect/js/tzdetect.js index bc25692..597a63c 100644 --- a/tz_detect/static/tz_detect/js/tzdetect.js +++ b/tz_detect/static/tz_detect/js/tzdetect.js @@ -66,7 +66,9 @@ xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlHttp.setRequestHeader(window.csrf_header_name, window.csrf_token); xmlHttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xmlHttp.send("offset=" + (new Date()).getTimezoneOffset() + '&timezone=' + Intl.DateTimeFormat().resolvedOptions().timeZone); + xmlHttp.send("offset=" + (new Date()).getTimezoneOffset() + + '&timezone=' + encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone) + ); } }()); \ No newline at end of file