Skip to content

Commit 61319c6

Browse files
authored
Update FormatRules.php
Removed $data in docs. Added check if $ip is binary string to do not check inet_ntop on human readable strings.
1 parent 5920c26 commit 61319c6

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

system/Validation/FormatRules.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,10 @@ public function valid_emails(string $str = null): bool
341341
//--------------------------------------------------------------------
342342

343343
/**
344-
* Validate an IP address
344+
* Validate an IP address (human readable format or binary string - inet_pton)
345345
*
346346
* @param string $ip IP Address
347347
* @param string $which IP protocol: 'ipv4' or 'ipv6'
348-
* @param array $data
349348
*
350349
* @return boolean
351350
*/
@@ -364,7 +363,7 @@ public function valid_ip(string $ip = null, string $which = null): bool
364363
break;
365364
}
366365

367-
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which) || (bool) filter_var(inet_ntop($ip), FILTER_VALIDATE_IP, $which);
366+
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which) || (!ctype_print($ip) && (bool) filter_var(inet_ntop($ip), FILTER_VALIDATE_IP, $which));
368367
}
369368

370369
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)