diff --git a/DnsServerCore/www/js/main.js b/DnsServerCore/www/js/main.js index 2dccc8dc..6ceae45d 100644 --- a/DnsServerCore/www/js/main.js +++ b/DnsServerCore/www/js/main.js @@ -378,7 +378,7 @@ function login(username, password) { var btn = $("#btnLogin").button('loading'); HTTPRequest({ - url: "/api/login?user=" + username + "&pass=" + password, + url: "/api/login?user=" + encodeURIComponent(username) + "&pass=" + encodeURIComponent(password), success: function (responseJSON) { token = responseJSON.token; @@ -449,7 +449,7 @@ function changePassword() { var btn = $("#btnChangePasswordSave").button('loading'); HTTPRequest({ - url: "/api/changePassword?token=" + token + "&pass=" + newPassword, + url: "/api/changePassword?token=" + token + "&pass=" + encodeURIComponent(newPassword), success: function (responseJSON) { $("#modalChangePassword").modal("hide"); btn.button('reset'); @@ -682,7 +682,7 @@ function saveDnsSettings() { proxy = "&proxyType=" + proxyType; } else { - proxy = "&proxyType=" + proxyType + "&proxyAddress=" + $("#txtProxyAddress").val() + "&proxyPort=" + $("#txtProxyPort").val() + "&proxyUsername=" + $("#txtProxyUsername").val() + "&proxyPassword=" + $("#txtProxyPassword").val(); + proxy = "&proxyType=" + proxyType + "&proxyAddress=" + $("#txtProxyAddress").val() + "&proxyPort=" + $("#txtProxyPort").val() + "&proxyUsername=" + encodeURIComponent($("#txtProxyUsername").val()) + "&proxyPassword=" + encodeURIComponent($("#txtProxyPassword").val()); } var forwarders = cleanTextList($("#txtForwarders").val()); @@ -696,18 +696,15 @@ function saveDnsSettings() { var blockListUrls = cleanTextList($("#txtBlockListUrls").val()); - if ((blockListUrls.length === 0) || (blockListUrls === ",")) { + if ((blockListUrls.length === 0) || (blockListUrls === ",")) blockListUrls = false; - } - else { + else $("#txtBlockListUrls").val(blockListUrls.replace(/,/g, "\n") + "\n"); - blockListUrls = window.btoa(blockListUrls); - } var btn = $("#btnSaveDnsSettings").button('loading'); HTTPRequest({ - url: "/api/setDnsSettings?token=" + token + "&serverDomain=" + serverDomain + "&webServicePort=" + webServicePort + "&dnsServerLocalAddresses=" + dnsServerLocalAddresses + "&preferIPv6=" + preferIPv6 + "&logQueries=" + logQueries + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + proxy + "&forwarders=" + forwarders + "&forwarderProtocol=" + forwarderProtocol + "&blockListUrls=" + blockListUrls, + url: "/api/setDnsSettings?token=" + token + "&serverDomain=" + serverDomain + "&webServicePort=" + webServicePort + "&dnsServerLocalAddresses=" + encodeURIComponent(dnsServerLocalAddresses) + "&preferIPv6=" + preferIPv6 + "&logQueries=" + logQueries + "&allowRecursion=" + allowRecursion + "&allowRecursionOnlyForPrivateNetworks=" + allowRecursionOnlyForPrivateNetworks + proxy + "&forwarders=" + encodeURIComponent(forwarders) + "&forwarderProtocol=" + forwarderProtocol + "&blockListUrls=" + encodeURIComponent(blockListUrls), success: function (responseJSON) { document.title = "Technitium DNS Server " + responseJSON.response.version + " - " + responseJSON.response.serverDomain; $("#lblServerDomain").text(" - " + responseJSON.response.serverDomain); @@ -1623,13 +1620,13 @@ function renderStandardResourceRecord(record, domain) { html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //value html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //ttl @@ -1640,7 +1637,7 @@ function renderStandardResourceRecord(record, domain) { //buttons html += "
"; - html += "
"; + html += "
"; html += ""; html += ""; html += ""; @@ -1681,13 +1678,13 @@ function renderMXResourceRecord(record, domain) { html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //exchange html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //preference @@ -1704,7 +1701,7 @@ function renderMXResourceRecord(record, domain) { //buttons html += "
"; - html += "
"; + html += "
"; html += ""; html += ""; html += ""; @@ -1744,19 +1741,19 @@ function renderSOAResourceRecord(record, domain) { html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //master name server html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //responsible person html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //serial @@ -1850,19 +1847,19 @@ function renderSRVResourceRecord(record, domain) { //name html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //service html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //protocol html += "
"; html += ""; - html += ""; + html += ""; html += "
"; //priority @@ -1897,7 +1894,7 @@ function renderSRVResourceRecord(record, domain) { //buttons html += "
"; - html += "
"; + html += "
"; html += ""; html += ""; html += ""; @@ -2264,7 +2261,7 @@ function addResourceRecord() { ttl = 3600; } - var apiUrl = "/api/addRecord?token=" + token + "&domain=" + name + "&type=" + type + "&ttl=" + ttl + "&value=" + value; + var apiUrl = "/api/addRecord?token=" + token + "&domain=" + encodeURIComponent(name) + "&type=" + type + "&ttl=" + ttl + "&value=" + encodeURIComponent(value); switch (type) { case "MX": @@ -2327,7 +2324,7 @@ function deleteResourceRecord(objBtn) { if (!confirm("Are you sure to permanently delete the " + type + " record '" + name + "' with value '" + value + "'?")) return false; - var apiUrl = "/api/deleteRecord?token=" + token + "&domain=" + name + "&type=" + type + "&value=" + value; + var apiUrl = "/api/deleteRecord?token=" + token + "&domain=" + name + "&type=" + type + "&value=" + encodeURIComponent(value); if (type === "SRV") { var port = $("#txtPort" + id).val(); @@ -2494,7 +2491,7 @@ function updateResourceRecord(objBtn, disable) { break; } - var apiUrl = "/api/updateRecord?token=" + token + "&type=" + type + "&domain=" + newName + "&oldDomain=" + oldName + "&value=" + newValue + "&oldValue=" + oldValue + "&ttl=" + ttl + "&disable=" + disable; + var apiUrl = "/api/updateRecord?token=" + token + "&type=" + type + "&domain=" + newName + "&oldDomain=" + oldName + "&value=" + encodeURIComponent(newValue) + "&oldValue=" + encodeURIComponent(oldValue) + "&ttl=" + ttl + "&disable=" + disable; switch (type) { case "MX": @@ -2624,7 +2621,7 @@ function resolveQuery(importRecords) { divDnsClientLoader.show(); HTTPRequest({ - url: "/api/resolveQuery?token=" + token + "&server=" + server + "&domain=" + domain + "&type=" + type + "&protocol=" + protocol + (importRecords ? "&import=true" : ""), + url: "/api/resolveQuery?token=" + token + "&server=" + encodeURIComponent(server) + "&domain=" + encodeURIComponent(domain) + "&type=" + type + "&protocol=" + protocol + (importRecords ? "&import=true" : ""), success: function (responseJSON) { preDnsClientOutput.text(JSON.stringify(responseJSON.response.result, null, 2));