Skip to content

Commit 5d0e31b

Browse files
committed
Apply suggestion from !1358
1 parent 571ca4e commit 5d0e31b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

interface/lib/classes/validate_dns.inc.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ function validate_ip($field_name, $field_value, $validator) {
305305
// Check if it's a valid input
306306
foreach($field_value_array as $field_value) {
307307
// Check if the IP is valid without range
308-
$ip = strstr($field_value, '/', true) ?: $field_value;
309-
if (strpos($field_value, '/') !== false) {
310-
$subnet = strstr($field_value, '/', false);
311-
$subnet = ltrim($subnet, "/");
308+
$subnet = '';
309+
$ip = $field_value;
310+
if(strpos($ip, '/') !== false) {
311+
list($ip, $subnet) = explode('/', $ip, 2);
312+
$ip = trim($ip);
313+
$subnet = intval($subnet);
312314
}
313315
if(function_exists('filter_var')) {
314316
if(!filter_var($ip, FILTER_VALIDATE_IP)) {

0 commit comments

Comments
 (0)