From 3ec55dbf0a318d39caa5405e92e741f0ab269d94 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 22 Nov 2017 13:25:23 -0500 Subject: [PATCH] Improve domain whitespace handling in inputs --- scripts/pi-hole/js/list.js | 2 +- scripts/pi-hole/js/queryads.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/pi-hole/js/list.js b/scripts/pi-hole/js/list.js index 664d64b2..e438f1b9 100644 --- a/scripts/pi-hole/js/list.js +++ b/scripts/pi-hole/js/list.js @@ -141,7 +141,7 @@ function add(arg) { $.ajax({ url: "scripts/pi-hole/php/add.php", method: "post", - data: {"domain":domain.val(), "list":locallistType, "token":token}, + data: {"domain":domain.val().trim(), "list":locallistType, "token":token}, success: function(response) { if (response.indexOf("] Pi-hole blocking is ") === -1) { alFailure.show(); diff --git a/scripts/pi-hole/js/queryads.js b/scripts/pi-hole/js/queryads.js index 5d56068f..b86a0309 100644 --- a/scripts/pi-hole/js/queryads.js +++ b/scripts/pi-hole/js/queryads.js @@ -57,9 +57,10 @@ function httpGet(ta,quiet,theUrl) function eventsource() { var ta = $("#output"); - var domain = $("#domain"); + var domain = $("#domain").val().trim(); var q = $("#quiet"); - if(domain.val().length === 0) + + if(domain.length === 0) { return; } @@ -73,12 +74,12 @@ function eventsource() { // IE does not support EventSource - load whole content at once if (typeof EventSource !== "function") { - httpGet(ta,quiet,"/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+exact+"&IE"); + httpGet(ta,quiet,"/admin/scripts/pi-hole/php/queryads.php?domain="+domain.toLowerCase()+exact+"&IE"); return; } var host = window.location.host; - var source = new EventSource("/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+"&"+exact); + var source = new EventSource("/admin/scripts/pi-hole/php/queryads.php?domain="+domain.toLowerCase()+"&"+exact); // Reset and show field ta.empty();