spfcheck : Generate an error if the mask in IP4 or IP6 is too wide
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@6029 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -196,6 +196,18 @@ class spfcheckTest extends PHPUnit_Framework_TestCase
|
||||
"mx" => array ())));
|
||||
}
|
||||
|
||||
public function test_wideIPRange ()
|
||||
{
|
||||
$spfcheck = new spfcheck ();
|
||||
$spfcheck->getRecords ("wide.spf.tester.fournier38.fr");
|
||||
$res = $spfcheck->getErrors ();
|
||||
$this->assertSame ($res,
|
||||
array ("wide.spf.tester.fournier38.fr" => array (
|
||||
"ip4:213.131.32.0/2" => "Invalid ip4 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/2' too wide",
|
||||
"ip6:2001::/20" => "Invalid ip6 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/20' too wide"
|
||||
)));
|
||||
}
|
||||
|
||||
public function test_getRecords_Unknown ()
|
||||
{
|
||||
$spfcheck = new spfcheck ();
|
||||
|
||||
18
spfcheck.php
18
spfcheck.php
@@ -320,6 +320,15 @@ class spfcheck
|
||||
$domain, $ext);
|
||||
continue;
|
||||
}
|
||||
if ($mask !== "" &&
|
||||
filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) &&
|
||||
substr ($mask, 1) < 16)
|
||||
{
|
||||
$this->errors[$domain][$part] = sprintf (dgettext ("domframework",
|
||||
"Invalid ip4 set for domain '%s' : Mask '%s' too wide"),
|
||||
$domain, $mask);
|
||||
continue;
|
||||
}
|
||||
$ips[$domain][$part][] = $ip.$mask;
|
||||
}
|
||||
// }}}
|
||||
@@ -343,6 +352,15 @@ class spfcheck
|
||||
$domain, $ext);
|
||||
continue;
|
||||
}
|
||||
if ($mask !== "" &&
|
||||
filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) &&
|
||||
substr ($mask, 1) < 64)
|
||||
{
|
||||
$this->errors[$domain][$part] = sprintf (dgettext ("domframework",
|
||||
"Invalid ip6 set for domain '%s' : Mask '%s' too wide"),
|
||||
$domain, $mask);
|
||||
continue;
|
||||
}
|
||||
$ips[$domain][$part][] = $ip.$mask;
|
||||
}
|
||||
// }}}
|
||||
|
||||
Reference in New Issue
Block a user