From d998c5cf12d1bfa4da7b3e0c21555b230d989bca Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 27 Apr 2010 21:48:44 -0400 Subject: Add input validation for the Backends form --- config/varnish64/varnish.inc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'config/varnish64/varnish.inc') diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc index 7535b1bb..735152f7 100644 --- a/config/varnish64/varnish.inc +++ b/config/varnish64/varnish.inc @@ -31,12 +31,33 @@ */ /* ========================================================================== */ +function varnish_backends_post_validate($post, $input_errors) { + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $post['backendname'])) + $input_errors[] = "The backend name must only contain the characters a-Z or 0-9"; + if(!is_ipaddr($post['ipaddress'])) + $input_errors[] = "A valid IP address is required for the field 'IPAddress'"; + if($post['first_byte_timeout'] && !is_int($post['first_byte_timeout'])) + $input_errors[] = "A valid number is required for the field 'first byte timeout'"; + if($post['connect_timeout'] && !is_int($post['connect_timeout'])) + $input_errors[] = "A valid number is required for the field 'connect timeout'"; + if($post['probe_interval'] && !is_int($post['probe_interval'])) + $input_errors[] = "A valid number is required for the field 'probe interval'"; + if($post['probe_interval'] && !is_int($post['probe_interval'])) + $input_errors[] = "A valid number is required for the field 'probe interval'"; + if($post['probe_timeout'] && !is_int($post['probe_timeout'])) + $input_errors[] = "A valid number is required for the field 'probe timeout'"; + if($post['probe_window'] && !is_int($post['probe_window'])) + $input_errors[] = "A valid number is required for the field 'probe window'"; + if($post['probe_threshold'] && !is_int($post['probe_threshold'])) + $input_errors[] = "A valid number is required for the field 'probe threshold'"; +} + function varnish_install() { - create_varnish_rcd_file(); + create_varnish_rcd_file(); } function varnish_deinstall() { - create_varnish_rcd_file(); + create_varnish_rcd_file(); } function varnish_start() { -- cgit v1.2.3