From eaaff3187adf15a45e056fd7f761c447bf021425 Mon Sep 17 00:00:00 2001 From: Samuel Demirdjian Date: Thu, 6 Oct 2016 15:46:56 +0300 Subject: [PATCH] Throw exception in Valid::ip on some incompatible minor versions PHP 5.6.25, 5.6.26, 7.0.10, 7.0.11 include backward incompatible bugfixes which later were reverted in the minor versions that followed. See https://github.com/php/php-src/pull/1954 --- classes/Kohana/Valid.php | 9 +++++++++ tests/kohana/ValidTest.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/classes/Kohana/Valid.php b/classes/Kohana/Valid.php index 9c14b0e06..712fb244e 100644 --- a/classes/Kohana/Valid.php +++ b/classes/Kohana/Valid.php @@ -224,6 +224,15 @@ public static function url($url) */ public static function ip($ip, $allow_private = TRUE) { + $versions_to_skip = array('5.6.25', '5.6.26', '7.0.10', '7.0.11'); + foreach ($versions_to_skip as $version) + { + if (version_compare(PHP_VERSION, $version, '==')) + { + throw new Kohana_Exception("Valid::ip not compatible with PHP $version"); + } + } + // Do not allow reserved addresses $flags = FILTER_FLAG_NO_RES_RANGE; diff --git a/tests/kohana/ValidTest.php b/tests/kohana/ValidTest.php index 764e04947..d234a425a 100644 --- a/tests/kohana/ValidTest.php +++ b/tests/kohana/ValidTest.php @@ -593,6 +593,15 @@ public function provider_ip() */ public function test_ip($input_ip, $allow_private, $expected_result) { + $versions_to_skip = array('5.6.25', '5.6.26', '7.0.10', '7.0.11'); + foreach ($versions_to_skip as $version) + { + if (version_compare(PHP_VERSION, $version, '==')) + { + $this->setExpectedException('Kohana_Exception'); + } + } + $this->assertEquals( $expected_result, Valid::ip($input_ip, $allow_private)