From de15123b4eecfb35da832f490abd37196244470d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Oct 2023 12:47:44 +0200 Subject: [PATCH 01/19] Build HTTPS URL using Javascript to ensure we use the exact same URL the user used to get there - do not hard-code pi.hole as hostname Signed-off-by: DL6ER --- login.lp | 11 +---------- scripts/pi-hole/js/login.js | 6 ++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/login.lp b/login.lp index 8d139a53f..8d4b4bda8 100644 --- a/login.lp +++ b/login.lp @@ -8,15 +8,6 @@ --]] mg.include('scripts/pi-hole/lua/header.lp','r') - --- Build HTTPS upgrade link if HTTP is used -https_link = "" -if not is_secure then - https_link = "https://pi.hole" .. mg.request_info.request_uri - if mg.request_info.query_string then - https_link = https_link .. "?" .. mg.request_info.query_string - end -end ?>
-

Consider upgrading to HTTPS (end-to-end encryption)

+

Consider upgrading to HTTPS (end-to-end encryption)

diff --git a/scripts/pi-hole/js/login.js b/scripts/pi-hole/js/login.js index cb900c2c3..b394dd95e 100644 --- a/scripts/pi-hole/js/login.js +++ b/scripts/pi-hole/js/login.js @@ -117,4 +117,10 @@ $(function () { // Clear TOTP field $("#totp").val(""); + + // Generate HTTPS redirection link (only used if not already HTTPS) + if (location.protocol !== "https:") { + const url = "https:" + location.href.substring(location.protocol.length); + $("#https-link").attr("href", url); + } }); From eaf068c5063bd1087ce4d4a4c26113745055592e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Oct 2023 19:35:02 +0200 Subject: [PATCH 02/19] Show HTTPS hint on login page only when HTTPS is actually served. If it is served an a port != 443, add this port as well Signed-off-by: DL6ER --- login.lp | 4 ++-- scripts/pi-hole/js/login.js | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/login.lp b/login.lp index 8d4b4bda8..30e002b1f 100644 --- a/login.lp +++ b/login.lp @@ -26,8 +26,8 @@ mg.include('scripts/pi-hole/lua/header.lp','r') -
-
+
From 01366da32f1443ed1277652d9ec029493f13c2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 21:31:14 +0200 Subject: [PATCH 10/19] adminlte > web MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .github/ISSUE_TEMPLATE.md | 4 ++-- package.json | 6 +++--- scripts/pi-hole/js/footer.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 829de9da1..0ed8a37a3 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ **In raising this issue, I confirm the following:** `{please fill the checkboxes, e.g: [X]}` -- [] I have read and understood the [contributors guide](https://github.com/pi-hole/AdminLTE/blob/master/CONTRIBUTING.md). +- [] I have read and understood the [contributors guide](https://github.com/pi-hole/web/blob/master/CONTRIBUTING.md). - [] The issue I am reporting can be _replicated_. -- [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/AdminLTE/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/AdminLTE/issues)). +- [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/web/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/web/issues)). **How familiar are you with the the source code relevant to this issue?:** diff --git a/package.json b/package.json index a7eef41c1..6449d7162 100644 --- a/package.json +++ b/package.json @@ -5,15 +5,15 @@ "description": "", "repository": { "type": "git", - "url": "git+https://github.com/pi-hole/AdminLTE.git" + "url": "git+https://github.com/pi-hole/web.git" }, "keywords": [], "author": "", "license": "EUPL-1.2", "bugs": { - "url": "https://github.com/pi-hole/AdminLTE/issues" + "url": "https://github.com/pi-hole/web/issues" }, - "homepage": "https://github.com/pi-hole/AdminLTE#readme", + "homepage": "https://github.com/pi-hole/web#readme", "scripts": { "prefix": "postcss \"style/*.css\" \"style/themes/*.css\" --use autoprefixer --no-map --replace", "prettier:check": "prettier -l \"style/*.css\" \"style/themes/*.css\" \"scripts/pi-hole/**/*.js\"", diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 3ebbfc09a..4fd4050af 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -490,7 +490,7 @@ function updateVersionInfo() { remote: version.web.remote.version, branch: version.web.local.branch, hash: version.web.local.hash, - url: "https://github.com/pi-hole/AdminLTE/releases", + url: "https://github.com/pi-hole/web/releases", }, ]; From d4d07f766a9cc618c52cf3071ec84f4807bb5d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:04:29 +0200 Subject: [PATCH 11/19] Fix update logic for custom branches by comparing hashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 52 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 4fd4050af..65cb4f29d 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -474,6 +474,7 @@ function updateVersionInfo() { remote: version.core.remote.version, branch: version.core.local.branch, hash: version.core.local.hash, + hash_remote: version.core.remote.hash, url: "https://github.com/pi-hole/pi-hole/releases", }, { @@ -482,6 +483,7 @@ function updateVersionInfo() { remote: version.ftl.remote.version, branch: version.ftl.local.branch, hash: version.ftl.local.hash, + hash_remote: version.ftl.remote.hash, url: "https://github.com/pi-hole/FTL/releases", }, { @@ -490,6 +492,7 @@ function updateVersionInfo() { remote: version.web.remote.version, branch: version.web.local.branch, hash: version.web.local.hash, + hash_remote: version.web.remote.hash, url: "https://github.com/pi-hole/web/releases", }, ]; @@ -508,23 +511,38 @@ function updateVersionInfo() { '" rel="noopener" target="_blank">' + localVersion + ""; - } else localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - - if (versionCompare(v.local, v.remote) === -1) { - if (v.name === "Docker Tag") dockerUpdate = true; - else updateAvailable = true; - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } + if (versionCompare(v.local, v.remote) === -1) { + // Update available + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } else { + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } } }); From 5cd83cfa2482f95c20d92a68ee01799f91fd3f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:19:11 +0200 Subject: [PATCH 12/19] Remove duplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 65cb4f29d..bdae70ee4 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -513,36 +513,29 @@ function updateVersionInfo() { ""; if (versionCompare(v.local, v.remote) === -1) { // Update available - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - } else { - // non-master branch - localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { - // hash differ > Update available - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); + updateAvailable = true; } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + updateAvailable = true; + } } } + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } } }); From fc542f5f86da5b45fc320d6fd478605e026f3210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:49:22 +0200 Subject: [PATCH 13/19] Close at the right place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 43 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index bdae70ee4..46a619c66 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -514,30 +514,29 @@ function updateVersionInfo() { if (versionCompare(v.local, v.remote) === -1) { // Update available updateAvailable = true; - } else { - // non-master branch - localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { - // hash differ > Update available - updateAvailable = true; - } + } + } else { + // non-master branch + localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; + if (v.hash != v.hash_remote) { + // hash differ > Update available + updateAvailable = true; } } - if (updateAvailable) { - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - } - }); + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + }}); if (dockerUpdate) $("update-hint").html( From bde139638927470d876eb7a4237b9b34e3bd3862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 22:52:54 +0200 Subject: [PATCH 14/19] Fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 46a619c66..a1628c897 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -518,25 +518,27 @@ function updateVersionInfo() { } else { // non-master branch localVersion = "vDev (" + v.branch + ", " + v.hash + ")"; - if (v.hash != v.hash_remote) { + if (v.hash !== v.hash_remote) { // hash differ > Update available updateAvailable = true; } } - if (updateAvailable) { - $("#versions").append( - "
  • " + - v.name + - " " + - localVersion + - '· Update available!
  • ' - ); - } else { - $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); - } - }}); + + if (updateAvailable) { + $("#versions").append( + "
  • " + + v.name + + " " + + localVersion + + '· Update available!
  • ' + ); + } else { + $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); + } + } + }); if (dockerUpdate) $("update-hint").html( From 45b1c667988c6ab9a435b8645116a5df67cf6aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 11 Oct 2023 23:06:49 +0200 Subject: [PATCH 15/19] Add check for Docker tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/footer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index a1628c897..70bc1d391 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -524,6 +524,11 @@ function updateVersionInfo() { } } + if (v.name === "Docker Tag" && versionCompare(v.local, v.remote) === -1) { + updateAvailable = true; + dockerUpdate = true; + } + if (updateAvailable) { $("#versions").append( "
  • " + From 1376f0a41ed907618401fa6eaabf6fca42c4977b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 12 Oct 2023 10:23:56 +0200 Subject: [PATCH 16/19] Show Theme Selector at basic level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- settings-api.lp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-api.lp b/settings-api.lp index 479da5601..0175a4a40 100644 --- a/settings-api.lp +++ b/settings-api.lp @@ -14,7 +14,7 @@ PageTitle = "Web Interface - API Settings" mg.include('scripts/pi-hole/lua/settings_header.lp','r') ?>
    -
    +
    From 95650820dc8f00683f1cd6dca18d1ff6e3837d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 12 Oct 2023 12:08:33 +0200 Subject: [PATCH 17/19] Active Sessions are an expert's thing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- settings-api.lp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings-api.lp b/settings-api.lp index 0175a4a40..0dd19b8fe 100644 --- a/settings-api.lp +++ b/settings-api.lp @@ -143,7 +143,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
    -
    +

    Currently active sessions

    From 114624896405249121582b3bb5061d03aa7a11e7 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 13 Oct 2023 09:41:10 +0200 Subject: [PATCH 18/19] Revert "Fix AJAX JSON data (#2742)" This reverts commit 340d373711c29a9eba0bba1afd94c3205ad943b2, reversing changes made to 1ed1efdc91320e36b2bcedcfb9e9c4f3b1402375. Signed-off-by: DL6ER --- scripts/pi-hole/js/footer.js | 5 ++--- scripts/pi-hole/js/groups-adlists.js | 6 +++--- scripts/pi-hole/js/groups-clients.js | 6 +++--- scripts/pi-hole/js/groups-domains.js | 8 ++++---- scripts/pi-hole/js/groups.js | 8 ++++---- scripts/pi-hole/js/login.js | 3 +-- scripts/pi-hole/js/settings-api.js | 3 +-- scripts/pi-hole/js/settings.js | 3 +-- scripts/pi-hole/js/utils.js | 4 ++-- 9 files changed, 21 insertions(+), 25 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 6cd7bfba4..70bc1d391 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -119,11 +119,10 @@ function piholeChange(action, duration) { $.ajax({ url: "/api/dns/blocking", method: "POST", - dataType: "json", - data: { + data: JSON.stringify({ blocking: action === "enable", timer: parseInt(duration, 10) > 0 ? parseInt(duration, 10) : null, - }, + }), }) .done(function (data) { if (data.blocking === action + "d") { diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 624972b3c..84ff709c2 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -516,7 +516,7 @@ function addAdlist(event) { url: "/api/lists", method: "post", dataType: "json", - data: { address: address, comment: comment, type: type }, + data: JSON.stringify({ address: address, comment: comment, type: type }), success: function () { utils.enableAll(); utils.showAlert("success", "fas fa-plus", "Successfully added " + type + "list", address); @@ -582,12 +582,12 @@ function editAdlist() { url: "/api/lists/" + encodeURIComponent(addressDecoded), method: "put", dataType: "json", - data: { + data: JSON.stringify({ groups: groups, comment: comment, enabled: enabled, type: type, - }, + }), success: function () { utils.enableAll(); utils.showAlert( diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 6a7aecefa..843be7b97 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -440,7 +440,7 @@ function addClient() { url: "/api/clients", method: "post", dataType: "json", - data: { client: ip, comment: comment }, + data: JSON.stringify({ client: ip, comment: comment }), success: function () { utils.enableAll(); utils.showAlert("success", "fas fa-plus", "Successfully added client", ip); @@ -495,12 +495,12 @@ function editClient() { url: "/api/clients/" + encodeURIComponent(clientDecoded), method: "put", dataType: "json", - data: { + data: JSON.stringify({ client: client, groups: groups, comment: comment, enabled: enabled, - }, + }), success: function () { utils.enableAll(); utils.showAlert( diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index 8158caf88..1429a95a1 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -527,12 +527,12 @@ function addDomain() { url: "/api/domains/" + type + "/" + kind, method: "post", dataType: "json", - data: { + data: JSON.stringify({ domain: domain, comment: comment, type: type, kind: kind, - }, + }), success: function () { utils.enableAll(); utils.showAlert("success", "fas fa-plus", "Successfully added domain", domain); @@ -609,13 +609,13 @@ function editDomain() { url: "/api/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded), method: "put", dataType: "json", - data: { + data: JSON.stringify({ groups: groups, comment: comment, enabled: enabled, type: oldType, kind: oldKind, - }, + }), success: function () { utils.enableAll(); utils.showAlert( diff --git a/scripts/pi-hole/js/groups.js b/scripts/pi-hole/js/groups.js index 5e8f99303..0beab5baf 100644 --- a/scripts/pi-hole/js/groups.js +++ b/scripts/pi-hole/js/groups.js @@ -294,11 +294,11 @@ function addGroup() { url: "/api/groups", method: "post", dataType: "json", - data: { + data: JSON.stringify({ name: name, comment: comment, enabled: true, - }, + }), success: function () { utils.enableAll(); utils.showAlert("success", "fas fa-plus", "Successfully added group", name); @@ -360,11 +360,11 @@ function editGroup() { url: "/api/groups/" + oldName, method: "put", dataType: "json", - data: { + data: JSON.stringify({ name: name, comment: comment, enabled: enabled, - }, + }), success: function () { utils.enableAll(); utils.showAlert("success", "fas fa-pencil-alt", "Successfully " + done + " group", oldName); diff --git a/scripts/pi-hole/js/login.js b/scripts/pi-hole/js/login.js index 4dc518f47..3f4028413 100644 --- a/scripts/pi-hole/js/login.js +++ b/scripts/pi-hole/js/login.js @@ -60,8 +60,7 @@ function doLogin(password) { $.ajax({ url: "/api/auth", method: "POST", - dataType: "json", - data: { password: password, totp: parseInt($("#totp").val(), 10) }, + data: JSON.stringify({ password: password, totp: parseInt($("#totp").val(), 10) }), }) .done(function () { wrongPassword(false, true); diff --git a/scripts/pi-hole/js/settings-api.js b/scripts/pi-hole/js/settings-api.js index 6bb17f678..b0e4fea21 100644 --- a/scripts/pi-hole/js/settings-api.js +++ b/scripts/pi-hole/js/settings-api.js @@ -318,8 +318,7 @@ function setTOTPSecret(secret) { $.ajax({ url: "/api/config", type: "PATCH", - dataType: "json", - data: { config: { webserver: { api: { totp_secret: secret } } } }, + data: JSON.stringify({ config: { webserver: { api: { totp_secret: secret } } } }), contentType: "application/json", }) .done(function () { diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index b7ef7265e..6922cdbb5 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -137,8 +137,7 @@ function saveSettings() { $.ajax({ url: "/api/config", method: "PATCH", - dataType: "json", - data: { config: settings }, + data: JSON.stringify({ config: settings }), contentType: "application/json; charset=utf-8", }) .done(function () { diff --git a/scripts/pi-hole/js/utils.js b/scripts/pi-hole/js/utils.js index 530725ab0..cbeb63041 100644 --- a/scripts/pi-hole/js/utils.js +++ b/scripts/pi-hole/js/utils.js @@ -315,12 +315,12 @@ function addFromQueryLog(domain, list) { url: "/api/domains/" + list + "/exact", method: "post", dataType: "json", - data: { + data: JSON.stringify({ domain: domain, comment: "Added from Query Log", type: list, kind: "exact", - }, + }), success: function (response) { alProcessing.hide(); if ("domains" in response && response.domains.length > 0) { From 43c8ede674aba2a492025a6f74d214388a4698e4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 13 Oct 2023 09:44:01 +0200 Subject: [PATCH 19/19] Add "processData: false" to all JSON data we send Signed-off-by: DL6ER --- scripts/pi-hole/js/footer.js | 2 ++ scripts/pi-hole/js/groups-adlists.js | 2 ++ scripts/pi-hole/js/groups-clients.js | 2 ++ scripts/pi-hole/js/groups-domains.js | 2 ++ scripts/pi-hole/js/groups.js | 2 ++ scripts/pi-hole/js/login.js | 2 ++ scripts/pi-hole/js/settings-api.js | 2 ++ scripts/pi-hole/js/settings-system.js | 2 ++ scripts/pi-hole/js/settings.js | 2 ++ scripts/pi-hole/js/utils.js | 1 + 10 files changed, 19 insertions(+) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 70bc1d391..289f104c9 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -119,6 +119,8 @@ function piholeChange(action, duration) { $.ajax({ url: "/api/dns/blocking", method: "POST", + dataType: "json", + processData: false, data: JSON.stringify({ blocking: action === "enable", timer: parseInt(duration, 10) > 0 ? parseInt(duration, 10) : null, diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 84ff709c2..c05a84ad3 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -516,6 +516,7 @@ function addAdlist(event) { url: "/api/lists", method: "post", dataType: "json", + processData: false, data: JSON.stringify({ address: address, comment: comment, type: type }), success: function () { utils.enableAll(); @@ -582,6 +583,7 @@ function editAdlist() { url: "/api/lists/" + encodeURIComponent(addressDecoded), method: "put", dataType: "json", + processData: false, data: JSON.stringify({ groups: groups, comment: comment, diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 843be7b97..32483b4f9 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -440,6 +440,7 @@ function addClient() { url: "/api/clients", method: "post", dataType: "json", + processData: false, data: JSON.stringify({ client: ip, comment: comment }), success: function () { utils.enableAll(); @@ -495,6 +496,7 @@ function editClient() { url: "/api/clients/" + encodeURIComponent(clientDecoded), method: "put", dataType: "json", + processData: false, data: JSON.stringify({ client: client, groups: groups, diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index 1429a95a1..d0f07e01e 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -527,6 +527,7 @@ function addDomain() { url: "/api/domains/" + type + "/" + kind, method: "post", dataType: "json", + processData: false, data: JSON.stringify({ domain: domain, comment: comment, @@ -609,6 +610,7 @@ function editDomain() { url: "/api/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded), method: "put", dataType: "json", + processData: false, data: JSON.stringify({ groups: groups, comment: comment, diff --git a/scripts/pi-hole/js/groups.js b/scripts/pi-hole/js/groups.js index 0beab5baf..fdb9ed360 100644 --- a/scripts/pi-hole/js/groups.js +++ b/scripts/pi-hole/js/groups.js @@ -294,6 +294,7 @@ function addGroup() { url: "/api/groups", method: "post", dataType: "json", + processData: false, data: JSON.stringify({ name: name, comment: comment, @@ -360,6 +361,7 @@ function editGroup() { url: "/api/groups/" + oldName, method: "put", dataType: "json", + processData: false, data: JSON.stringify({ name: name, comment: comment, diff --git a/scripts/pi-hole/js/login.js b/scripts/pi-hole/js/login.js index 3f4028413..ef1ff70fa 100644 --- a/scripts/pi-hole/js/login.js +++ b/scripts/pi-hole/js/login.js @@ -60,6 +60,8 @@ function doLogin(password) { $.ajax({ url: "/api/auth", method: "POST", + dataType: "json", + processData: false, data: JSON.stringify({ password: password, totp: parseInt($("#totp").val(), 10) }), }) .done(function () { diff --git a/scripts/pi-hole/js/settings-api.js b/scripts/pi-hole/js/settings-api.js index b0e4fea21..d2e80cc8a 100644 --- a/scripts/pi-hole/js/settings-api.js +++ b/scripts/pi-hole/js/settings-api.js @@ -318,6 +318,8 @@ function setTOTPSecret(secret) { $.ajax({ url: "/api/config", type: "PATCH", + dataType: "json", + processData: false, data: JSON.stringify({ config: { webserver: { api: { totp_secret: secret } } } }), contentType: "application/json", }) diff --git a/scripts/pi-hole/js/settings-system.js b/scripts/pi-hole/js/settings-system.js index a7f8b4256..c7f5c6477 100644 --- a/scripts/pi-hole/js/settings-system.js +++ b/scripts/pi-hole/js/settings-system.js @@ -290,6 +290,8 @@ $("#loggingButton").confirm({ $.ajax({ url: "/api/config/dns/queryLogging", type: "PATCH", + dataType: "json", + processData: false, data: JSON.stringify(data), }) .done(function (data) { diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 6922cdbb5..17d28f406 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -137,6 +137,8 @@ function saveSettings() { $.ajax({ url: "/api/config", method: "PATCH", + dataType: "json", + processData: false, data: JSON.stringify({ config: settings }), contentType: "application/json; charset=utf-8", }) diff --git a/scripts/pi-hole/js/utils.js b/scripts/pi-hole/js/utils.js index cbeb63041..b0795ff1b 100644 --- a/scripts/pi-hole/js/utils.js +++ b/scripts/pi-hole/js/utils.js @@ -315,6 +315,7 @@ function addFromQueryLog(domain, list) { url: "/api/domains/" + list + "/exact", method: "post", dataType: "json", + processData: false, data: JSON.stringify({ domain: domain, comment: "Added from Query Log",