Use preg_split() instead of explode() for better space handling. Skip empty domains in add_to_table() and remove_from_table().

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-08-07 21:23:29 +02:00
parent 7807f12d65
commit 71fc7a4791
3 changed files with 10 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ if(in_array($list, $check_lists)) {
}
// Split individual domains into array
$domains = explode(" ",$_POST['domain']);
$domains = preg_split('/\s+/', $_POST['domain']);
require_once("func.php");
require_once("database.php");

View File

@@ -81,6 +81,10 @@ function add_to_table($db, $table, $domains, $wildcardstyle=false)
$num = 0;
foreach($domains as $domain)
{
// Skip empty domains
if(strlen($domain) == 0)
continue;
if($wildcardstyle)
$domain = "(\\.|^)".str_replace(".","\\.",$domain)."$";
@@ -124,6 +128,10 @@ function remove_from_table($db, $table, $domains)
$num = 0;
foreach($domains as $domain)
{
// Skip empty domains
if(strlen($domain) == 0)
continue;
$stmt->bindValue(":domain", $domain, SQLITE3_TEXT);
if($stmt->execute() && $stmt->reset())

View File

@@ -17,7 +17,7 @@ if (empty($api)) {
}
// Split individual domains into array
$domains = explode(" ",$_POST['domain']);
$domains = preg_split('/\s+/', $_POST['domain']);
require_once("func.php");