diff --git a/tests/php/test_frames_query_requires_view.php b/tests/php/test_frames_query_requires_view.php index 7d92e02c44..f415638e63 100644 --- a/tests/php/test_frames_query_requires_view.php +++ b/tests/php/test_frames_query_requires_view.php @@ -178,6 +178,10 @@ namespace { check("advsearch that is $what is ignored", $r['outcome'], 'response'); } + // An array order falls back to the default instead of throwing. + $r = run_query($view, true, true, array('order' => array('asc'))); + check('array order is ignored', $r['outcome'], 'response'); + // Structural: the real file must route the event id through Event::canView() // before dispatching the query. Fails if the guard is reverted. $src = file_get_contents(__DIR__.'/../../web/ajax/frames.php'); diff --git a/tests/php/test_snapshots_ajax_bad_search.php b/tests/php/test_snapshots_ajax_bad_search.php index bf65a469e0..6e67d5a709 100644 --- a/tests/php/test_snapshots_ajax_bad_search.php +++ b/tests/php/test_snapshots_ajax_bad_search.php @@ -1,7 +1,8 @@ array('advsearch' => 'garbage'), 'array search' => array('search' => array('a')), + 'array sort' => array('sort' => array('Id')), + 'array order' => array('order' => array('asc')), ); // The ajax file declares functions, so each case runs in its own process. if (!isset($argv[1])) { diff --git a/web/ajax/console.php b/web/ajax/console.php index 573496a86e..ee4859dd4d 100644 --- a/web/ajax/console.php +++ b/web/ajax/console.php @@ -134,11 +134,11 @@ function queryRequest() { } // Get search parameter - $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; + $search = (isset($_REQUEST['search']) and is_string($_REQUEST['search'])) ? $_REQUEST['search'] : ''; // Get sort parameters - $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'Sequence'; - $order = isset($_REQUEST['order']) ? strtoupper($_REQUEST['order']) : 'ASC'; + $sort = (isset($_REQUEST['sort']) and is_string($_REQUEST['sort'])) ? $_REQUEST['sort'] : 'Sequence'; + $order = (isset($_REQUEST['order']) and is_string($_REQUEST['order'])) ? strtoupper($_REQUEST['order']) : 'ASC'; // Build monitor query with filters from request parameters, falling back to cookies $conditions = array(); diff --git a/web/ajax/frames.php b/web/ajax/frames.php index 229f828ed9..642cc1153d 100644 --- a/web/ajax/frames.php +++ b/web/ajax/frames.php @@ -35,7 +35,7 @@ if ( $message ) { } // Search contains a user entered string to search on -$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; +$search = (isset($_REQUEST['search']) and is_string($_REQUEST['search'])) ? $_REQUEST['search'] : ''; // Advanced search contains an array of "column name" => "search text" pairs // Bootstrap table sends json_ecoded array, which we must decode @@ -45,7 +45,7 @@ $advsearch = is_array($advsearch) ? $advsearch : array(); // Sort specifies the name of the column to sort on $sort = 'FrameId'; -if ( isset($_REQUEST['sort']) ) { +if ( isset($_REQUEST['sort']) and is_string($_REQUEST['sort']) ) { $sort = $_REQUEST['sort']; } @@ -60,7 +60,7 @@ if ( isset($_REQUEST['offset']) ) { } // Order specifies the sort direction, either asc or desc -$order = (isset($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC'; +$order = (isset($_REQUEST['order']) and is_string($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC'; // Limit specifies the number of rows to return $limit = 0; diff --git a/web/ajax/reports.php b/web/ajax/reports.php index 7bdd2f815a..a714e80b0b 100644 --- a/web/ajax/reports.php +++ b/web/ajax/reports.php @@ -32,15 +32,15 @@ require_once('includes/Filter.php'); require_once('includes/Report.php'); // Search contains a user entered string to search on -$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; +$search = (isset($_REQUEST['search']) and is_string($_REQUEST['search'])) ? $_REQUEST['search'] : ''; // Advanced search contains an array of "column name" => "search text" pairs // Bootstrap table sends json_ecoded array, which we must decode -$advsearch = isset($_REQUEST['advsearch']) ? json_decode($_REQUEST['advsearch'], JSON_OBJECT_AS_ARRAY) : array(); +$advsearch = (isset($_REQUEST['advsearch']) and is_string($_REQUEST['advsearch'])) ? json_decode($_REQUEST['advsearch'], JSON_OBJECT_AS_ARRAY) : array(); $order = 'ASC'; // Order specifies the sort direction, either asc or desc -if (isset($_REQUEST['order'])) { +if (isset($_REQUEST['order']) and is_string($_REQUEST['order'])) { if (strtolower($_REQUEST['order']) == 'asc') { $order = 'ASC'; } else if (strtolower($_REQUEST['order']) == 'desc') { @@ -51,7 +51,7 @@ if (isset($_REQUEST['order'])) { } // Sort specifies the name of the column to sort on -$sort = (isset($_REQUEST['sort'])) ? $_REQUEST['sort'] : ''; +$sort = (isset($_REQUEST['sort']) and is_string($_REQUEST['sort'])) ? $_REQUEST['sort'] : ''; // Offset specifies the starting row to return, used for pagination $offset = 0; diff --git a/web/ajax/snapshots.php b/web/ajax/snapshots.php index 633e063c67..fb7f450242 100644 --- a/web/ajax/snapshots.php +++ b/web/ajax/snapshots.php @@ -39,7 +39,7 @@ if (!is_array($advsearch)) $advsearch = array(); // Sort specifies the name of the column to sort on $sort = 'Id'; -if (isset($_REQUEST['sort'])) { +if (isset($_REQUEST['sort']) and is_string($_REQUEST['sort'])) { $sort = $_REQUEST['sort']; } @@ -54,7 +54,7 @@ if (isset($_REQUEST['offset'])) { } // Order specifies the sort direction, either asc or desc -$order = (isset($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC'; +$order = (isset($_REQUEST['order']) and is_string($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC'; // Limit specifies the number of rows to return // Set the default to 0 for events view, to prevent an issue with ALL pagination