From be44ab21a31c79f7a61f9e497ccaa3ff53c9d8dd Mon Sep 17 00:00:00 2001 From: marcelloc Date: Wed, 24 Aug 2011 04:53:57 -0300 Subject: fix managment post validation --- config/varnish64/varnish.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'config/varnish64') diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc index 4729ab7f..50d804fb 100644 --- a/config/varnish64/varnish.inc +++ b/config/varnish64/varnish.inc @@ -43,8 +43,11 @@ function varnish_settings_post_validate($post, $input_errors) { $input_errors[] = "A valid number is required for the field 'Maximum worker threads'"; if($post['timeoutworkers'] && !is_numeric($post['timeoutworkers'])) $input_errors[] = "A valid number is required for the field 'Worker thread timeout'"; - if($post['managment'] && !preg_match("/^\w+:\d+$/",$post['managment'])) - $input_errors[] = "A valid host/ip:port is required for the field 'managment'"; + if($post['managment']){ + $mgm= explode(":",$post['managment']); + if(!is_ipaddr($mgm[0]) || !is_numeric($mgm[1])) + $input_errors[] = "A valid ip:port is required for the field 'managment'"; + } if($post['grace'] && ! preg_match("/^\d+(h|m|s)$/",$post['grace'])) $input_errors[] = "A valid number with a time reference is required for the field 'Fetch grace'"; if($post['saint'] && ! preg_match("/^\d+(h|m|s)$/",$post['saint'])) -- cgit v1.2.3