Skip to content

Commit

Permalink
Avoid cname loops
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
  • Loading branch information
rdwebdesign committed Oct 20, 2022
1 parent 76bf7d7 commit 39f23fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/pi-hole/php/func.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,17 @@ function addCustomCNAMEEntry($domain = '', $target = '', $reload = '', $json = t
return returnError('Target must be valid', $json);
}

// Check if each submitted domain is valid
$domains = array_map('trim', explode(',', $domain));
foreach ($domains as $d) {
// Check if each submitted domain is valid
if (!validDomain($d)) {
return returnError("Domain '{$d}' is not valid", $json);
}

// Check if each submitted domain is different than the target to avoid loops
if (strtolower($d) === strtolower($target)) {
return returnError('Domain and target cannot be the same', $json);
}
}

$existingEntries = getCustomCNAMEEntries();
Expand Down

0 comments on commit 39f23fd

Please sign in to comment.