From e55ccc990b97de66e84b603af091575fade53ba3 Mon Sep 17 00:00:00 2001 From: Andrew Cobby Date: Wed, 10 Oct 2012 22:26:38 +1100 Subject: [PATCH] Fix budget info sanitisation --- src/DGM/Service/BudgetPersister.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/DGM/Service/BudgetPersister.php b/src/DGM/Service/BudgetPersister.php index cd3a62c..bd60ad2 100644 --- a/src/DGM/Service/BudgetPersister.php +++ b/src/DGM/Service/BudgetPersister.php @@ -37,13 +37,23 @@ public function sanitize() { foreach ($this->data as $key => $value) { if ($key == "name" || $key == "email" || $key == "description") { - $this->data[$key] = trim($value); - $this->data[$key] = strip_tags($value); + $value = trim($value); + $value = strip_tags($value); + } + + if ($key == "name" || $key == "email") { + $value = substr($value, 0, 50); + } + + if ($key == "description") { + $value = substr($value, 0, 500); } if (isset(Budget::$categoryData[$key])) { - $this->data[$key] = (float) $value; + $value = (float) $value; } + + $this->data[$key] = $value; } }