From 48e7516b6ebce0f4afc91d30acaffa59392bcbc8 Mon Sep 17 00:00:00 2001 From: Benton Snyder Date: Mon, 9 Dec 2013 18:39:19 -0600 Subject: [PATCH] HTTP POST strings fail integer validation https://github.com/enovance/phpipam/blob/master/api/models/subnet.php includes the following validation: if($this->allowRequests != 0 || $this->allowRequests !=1) { throw new Exception('Invalid allow requests value'); } if($this->showName != 0 || $this->showName !=1) { throw new Exception('Invalid show Name value'); } if($this->pingSubnet != 0 || $this->pingSubnet !=1) { throw new Exception('Invalid ping subnet value'); } These validations will always fail sine HTTP POST variables are strings. --- api/controllers/Subnets.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/controllers/Subnets.php b/api/controllers/Subnets.php index 94682ab..92d1cd6 100644 --- a/api/controllers/Subnets.php +++ b/api/controllers/Subnets.php @@ -43,10 +43,10 @@ public function createSubnets($_params) $subnet->description = $this->_params['description']; $subnet->vrfId = $this->_params['vrfId']; $subnet->vlanId = $this->_params['vlanId']; - $subnet->allowRequests = $this->_params['allowRequests']; - $subnet->showName = $this->_params['showName']; + $subnet->allowRequests = intval($this->_params['allowRequests']); + $subnet->showName = intval($this->_params['showName']); $subnet->permissions = $this->_params['permissions']; - $subnet->pingSubnet = $this->_params['pingSubnet']; + $subnet->pingSubnet = intval($this->_params['pingSubnet']); //create section $res = $subnet->createSubnet(); @@ -101,4 +101,4 @@ public function deleteSubnets() } } -?> \ No newline at end of file +?>