summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-01-30 21:43:41 +0100
committerAndrey Andreev <narf@devilix.net>2016-01-30 21:43:41 +0100
commit391d339b921623ce921bdb5520fb93f9cf62fac5 (patch)
tree978fa5b92448b56eb6ddfb0012131d7fb04b4063 /system/libraries
parent9aab22e0a1aa876b98dcfa58781b0ffde71f97a1 (diff)
Fix #4415 and add unit tests for https://bugs.php.net/bug.php?id=51192
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Form_validation.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 31632762d..ea3bc6de7 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1214,6 +1214,14 @@ class CI_Form_validation {
$str = $matches[2];
}
+ // PHP 7 accepts IPv6 addresses within square brackets as hostnames,
+ // but it appears that the PR that came in with https://bugs.php.net/bug.php?id=68039
+ // was never merged into a PHP 5 branch ... https://3v4l.org/8PsSN
+ if (preg_match('/^\[([^\]]+)\]/', $str, $matches) && ! is_php('7') && filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE)
+ {
+ $str = 'ipv6.host'.substr($str, strlen($matches[1]) + 2);
+ }
+
$str = 'http://'.$str;
// There's a bug affecting PHP 5.2.13, 5.3.2 that considers the