Merge pull request #867 from pi-hole/fix/query-ads-domain-option

Prevent domains sent to queryAds acting as command line options
This commit is contained in:
Mark Drobnak
2018-12-05 17:27:40 -05:00
committed by GitHub
+2 -1
View File
@@ -23,7 +23,8 @@ function echoEvent($datatext) {
ini_set("pcre.recursion_limit", 1500);
function is_valid_domain_name($domain_name)
{
return (preg_match("/^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/i", $domain_name) // Valid chars check
return ($domain_name[0] !== '-' // Don't allow domains to appear as command line options
&& preg_match("/^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/i", $domain_name) // Valid chars check
&& preg_match("/^.{1,253}$/", $domain_name) // Overall length check
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name) ); // Length of each label
}