diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-06-28 17:17:24 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-06-29 00:12:22 +0200 |
commit | 5d0aaf958325f500ce69cfb79e69eb0d8f83fdeb (patch) | |
tree | 96236bc76befde8b5eefe62c2c3ac5cb87141cc4 /inc | |
parent | 0189bd8669742c5290a4f6538f954b81554e26d2 (diff) | |
download | rpg-5d0aaf958325f500ce69cfb79e69eb0d8f83fdeb.tar.gz rpg-5d0aaf958325f500ce69cfb79e69eb0d8f83fdeb.tar.bz2 |
treat empty string inputs as unset for int and bool
Diffstat (limited to 'inc')
-rw-r--r-- | inc/Input.class.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/inc/Input.class.php b/inc/Input.class.php index 1ea5e031f..f4174404a 100644 --- a/inc/Input.class.php +++ b/inc/Input.class.php @@ -118,6 +118,7 @@ class Input { public function int($name, $default = 0, $nonempty = false) { if(!isset($this->access[$name])) return $default; if(is_array($this->access[$name])) return $default; + if($this->access[$name] === '') return $default; if($nonempty && empty($this->access[$name])) return $default; return (int) $this->access[$name]; @@ -151,6 +152,8 @@ class Input { */ public function bool($name, $default = false, $nonempty = false) { if(!isset($this->access[$name])) return $default; + if(is_array($this->access[$name])) return $default; + if($this->access[$name] === '') return $default; if($nonempty && empty($this->access[$name])) return $default; return (bool) $this->access[$name]; @@ -223,4 +226,4 @@ class GetInput extends Input { parent::set($name, $value); $_REQUEST[$name] = $value; } -}
\ No newline at end of file +} |