mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 12:14:36 -05:00
Merge pull request #6629 from singhharsh1708/fix/r2-ajax-array-sort-order
fix: list requests no longer fail when search, sort or order is an array
This commit is contained in:
6 files changed
+20
-13
No files matched your search
@@ -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');
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
// ajax/snapshots.php task=query: an advsearch value that is not a JSON object
|
||||
// decoded to null and count(null) threw a TypeError (HTTP 500); an array
|
||||
// search value was concatenated into a string.
|
||||
// search or sort value was concatenated into a string, and an array order
|
||||
// reached strtolower().
|
||||
// Run: php tests/php/test_snapshots_ajax_bad_search.php (from the repo root)
|
||||
|
||||
namespace ZM {
|
||||
@@ -21,6 +22,8 @@ namespace {
|
||||
$cases = array(
|
||||
'garbage advsearch' => 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])) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user