From b3b39b310e2292e274d0b3c52fbe5a900ba56d52 Mon Sep 17 00:00:00 2001 From: Jan Vansteenlandt Date: Wed, 20 Jan 2016 15:54:02 +0100 Subject: [PATCH] No empty query string parameters are allowed --- app/Tdt/Core/Formatters/HTMLFormatter.php | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Tdt/Core/Formatters/HTMLFormatter.php b/app/Tdt/Core/Formatters/HTMLFormatter.php index c493db26..dcb848af 100644 --- a/app/Tdt/Core/Formatters/HTMLFormatter.php +++ b/app/Tdt/Core/Formatters/HTMLFormatter.php @@ -30,7 +30,18 @@ public static function getBody($dataObj) $query_string = ''; if (!empty($_GET)) { - $query_string = '?' . http_build_query(\Input::all()); + $get_params = \Input::get(); + + foreach ($get_params as $param => $val) { + if (!empty($val)) { + $query_string .= "&$param=$val"; + } + } + + if (!empty($query_string)) { + $query_string = trim($query_string, '&'); + $query_string = '?' . $query_string; + } } // Links to pages @@ -38,11 +49,20 @@ public static function getBody($dataObj) $next_link = ''; if (!empty($dataObj->paging)) { - $input_array = array_except(\Input::all(), array('limit', 'offset')); + $input_array = array_except(\Input::get(), array('limit', 'offset')); $query_string = ''; if (!empty($input_array)) { - $query_string = '&' . http_build_query($input_array); + foreach ($get_params as $param => $val) { + if (!empty($val)) { + $query_string .= "&$param=$val"; + } + } + + if (!empty($query_string)) { + $query_string = trim($query_string, '&'); + $query_string = '?' . $query_string; + } } if (!empty($dataObj->paging['previous'])) {