[core] allow ip_in_range to match exact IPs

This commit is contained in:
Shish
2024-01-04 15:07:07 +00:00
parent c5395df243
commit e49fcfa0c7
2 changed files with 14 additions and 1 deletions

View File

@@ -226,4 +226,13 @@ class PolyfillsTest extends TestCase
stringer(["foo" => "bar", "baz" => [1,2,3], "qux" => ["a" => "b"]])
);
}
public function test_ip_in_range()
{
$this->assertTrue(ip_in_range("1.2.3.4", "1.2.0.0/16"));
$this->assertFalse(ip_in_range("4.3.2.1", "1.2.0.0/16"));
// A single IP should be interpreted as a /32
$this->assertTrue(ip_in_range("1.2.3.4", "1.2.3.4"));
}
}