diff --git a/scripts/pi-hole/php/groups.php b/scripts/pi-hole/php/groups.php index 157fc50b..4fdcdc88 100644 --- a/scripts/pi-hole/php/groups.php +++ b/scripts/pi-hole/php/groups.php @@ -640,15 +640,9 @@ if ($_POST['action'] == 'get_groups') { } } - if(isset($_POST['type']) && strlen($_POST['type']) === 2 && $_POST['type'][1] === 'W') + if( ! ($_POST['type'] == '2' || $_POST['type'] == '3')) { - // Apply wildcard-style formatting - $domain = "(\\.|^)".str_replace(".","\\.",$domain)."$"; - } - - if($type === ListType::whitelist || $type === ListType::blacklist) - { - // If adding to the exact lists, we convert the domain lower case and check whether it is valid + // If not adding a RegEx, we convert the domain lower case and check whether it is valid $domain = strtolower($domain); $msg = ""; if(!validDomain($domain, $msg)) @@ -664,6 +658,12 @@ if ($_POST['action'] == 'get_groups') { } } + if(isset($_POST['type']) && strlen($_POST['type']) === 2 && $_POST['type'][1] === 'W') + { + // Apply wildcard-style formatting + $domain = "(\\.|^)".str_replace(".","\\.",$domain)."$"; + } + // First try to delete any occurrences of this domain if we're in // replace mode. Only do this when the domain to be replaced is in // the default group! Otherwise, we would shuffle group settings and @@ -996,7 +996,7 @@ if ($_POST['action'] == 'get_groups') { if (!$stmt->execute()) { if ($db->lastErrorCode() == 19) { - // ErrorCode 19 is "Constraint violation", here the unique constraint of `address` + // ErrorCode 19 is "Constraint violation", here the unique constraint of `address` // is violated (https://www.sqlite.org/rescode.html#constraint). // If the list is already in database, add to ignored list, but don't throw error $ignored++;