Revert "HTMLPurifier filtering on searches"

This reverts commit b3b8e7ec1d.
This commit is contained in:
jekkos
2024-08-03 23:16:31 +02:00
parent e1f8b73005
commit d0992a92e7
17 changed files with 43 additions and 78 deletions

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Attribute;
use Config\Services;
require_once('Secure_Controller.php');
@@ -38,7 +37,7 @@ class Attributes extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -6,14 +6,13 @@ use App\Models\Cashup;
use App\Models\Expense;
use App\Models\Reports\Summary_payments;
use Config\OSPOS;
use Config\Services;
class Cashups extends Secure_Controller
{
private Cashup $cashup;
private Expense $expense;
private Summary_payments $summary_payments;
private array $config;
private Cashup $cashup;
private Expense $expense;
private Summary_payments $summary_payments;
private array $config;
public function __construct()
{
@@ -43,7 +42,7 @@ class Cashups extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -125,8 +125,7 @@ class Customers extends Persons
*/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->customer->get_search_suggestions($search);
$suggestions = $this->customer->get_search_suggestions($this->request->getGet('term'), 25,true);
echo json_encode($suggestions);
}
@@ -136,8 +135,7 @@ class Customers extends Persons
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->customer->get_search_suggestions($search, 25, false);
$suggestions = $this->customer->get_search_suggestions($this->request->getPost('term'), 25, false);
echo json_encode($suggestions);
}

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Module;
use Config\Services;
/**
*
@@ -27,7 +26,7 @@ class Employees extends Persons
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
@@ -52,8 +51,7 @@ class Employees extends Persons
*/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->employee->get_search_suggestions($search, 25, true);
$suggestions = $this->employee->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), 25, true);
echo json_encode($suggestions);
}
@@ -63,8 +61,7 @@ class Employees extends Persons
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->employee->get_search_suggestions($search);
$suggestions = $this->employee->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}

View File

@@ -5,7 +5,6 @@ namespace App\Controllers;
use App\Models\Expense;
use App\Models\Expense_category;
use Config\OSPOS;
use Config\Services;
class Expenses extends Secure_Controller
{
@@ -45,7 +44,7 @@ class Expenses extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Expense_category;
use Config\Services;
class Expenses_categories extends Secure_Controller //TODO: Is this class ever used?
{
@@ -31,7 +30,7 @@ class Expenses_categories extends Secure_Controller //TODO: Is this class ever u
**/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -4,7 +4,6 @@ namespace App\Controllers;
use App\Models\Giftcard;
use Config\OSPOS;
use Config\Services;
class Giftcards extends Secure_Controller
{
@@ -32,7 +31,7 @@ class Giftcards extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
@@ -58,8 +57,7 @@ class Giftcards extends Secure_Controller
*/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->giftcard->get_search_suggestions($search, true);
$suggestions = $this->giftcard->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true);
echo json_encode($suggestions);
}
@@ -69,8 +67,7 @@ class Giftcards extends Secure_Controller
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->giftcard->get_search_suggestions($search);
$suggestions = $this->giftcard->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}

View File

@@ -7,7 +7,6 @@ use App\Libraries\Barcode_lib;
use App\Models\Item;
use App\Models\Item_kit;
use App\Models\Item_kit_items;
use Config\Services;
class Item_kits extends Secure_Controller
{
@@ -76,7 +75,7 @@ class Item_kits extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search')) ?? '';
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
@@ -101,8 +100,7 @@ class Item_kits extends Secure_Controller
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->item_kit->get_search_suggestions($search);
$suggestions = $this->item_kit->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}

View File

@@ -94,11 +94,11 @@ class Items extends Secure_Controller
**/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$search = $this->request->getGet('search');
$limit = $this->request->getGet('limit');
$offset = $this->request->getGet('offset');
$sort = $this->request->getGet('sort');
$order = $this->request->getGet('order');
$this->item_lib->set_item_location($this->request->getGet('stock_location'));
@@ -182,8 +182,7 @@ class Items extends Secure_Controller
'is_deleted' => $this->request->getPost('is_deleted') !== null
];
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->item->get_search_suggestions($search, $options);
$suggestions = $this->item->get_search_suggestions($this->request->getPostGet('term'), $options);
echo json_encode($suggestions);
}
@@ -195,8 +194,7 @@ class Items extends Secure_Controller
*/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->item->get_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = $this->item->get_search_suggestions($this->request->getGet('term'), ['search_custom' => false, 'is_deleted' => false], true);
echo json_encode($suggestions);
}

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Person;
use Config\Services;
use function Tamtamchik\NameCase\str_name_case;
abstract class Persons extends Secure_Controller
@@ -35,8 +34,7 @@ abstract class Persons extends Secure_Controller
*/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->person->get_search_suggestions($search);
$suggestions = $this->person->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}

View File

@@ -12,7 +12,6 @@ use App\Models\Receiving;
use App\Models\Stock_location;
use App\Models\Supplier;
use Config\OSPOS;
use Config\Services;
use ReflectionException;
class Receivings extends Secure_Controller
@@ -61,9 +60,8 @@ class Receivings extends Secure_Controller
*/
public function getItemSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('term'));
$suggestions = $this->item->get_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search));
$suggestions = $this->item->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)));
echo json_encode($suggestions);
}
@@ -76,9 +74,8 @@ class Receivings extends Secure_Controller
*/
public function getStockItemSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('term'));
$suggestions = $this->item->get_stock_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search));
$suggestions = $this->item->get_stock_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)));
echo json_encode($suggestions);
}

View File

@@ -20,7 +20,7 @@ use App\Models\Stock_location;
use App\Models\Tokens\Token_invoice_count;
use App\Models\Tokens\Token_customer;
use App\Models\Tokens\Token_invoice_sequence;
use Config\Services;
use CodeIgniter\Config\Services;
use Config\OSPOS;
use ReflectionException;
use stdClass;
@@ -185,9 +185,7 @@ class Sales extends Secure_Controller
public function getItemSearch(): void
{
$suggestions = [];
$receipt = $search = $this->request->getGet('term') != ''
? Services::htmlPurifier()->purify($this->request->getGet('term'))
: null;
$receipt = $search = $this->request->getGet('term') != '' ? $this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
if($this->sale_lib->get_mode() == 'return' && $this->sale->is_valid_receipt($receipt))
{
@@ -205,9 +203,7 @@ class Sales extends Secure_Controller
*/
public function suggest_search(): void
{
$search = $this->request->getPost('term') != ''
? Services::htmlPurifier()->purify($this->request->getPost('term'))
: null;
$search = $this->request->getPost('term') != '' ? $this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
$suggestions = $this->sale->get_search_suggestions($search);

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Supplier;
use Config\Services;
class Suppliers extends Persons
{
@@ -45,7 +44,7 @@ class Suppliers extends Persons
**/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
@@ -71,8 +70,7 @@ class Suppliers extends Persons
**/
public function getSuggest(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('term'));
$suggestions = $this->supplier->get_search_suggestions($search, true);
$suggestions = $this->supplier->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true);
echo json_encode($suggestions);
}
@@ -82,8 +80,7 @@ class Suppliers extends Persons
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->supplier->get_search_suggestions($search, false);
$suggestions = $this->supplier->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), false);
echo json_encode($suggestions);
}

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Tax_category;
use Config\Services;
/**
* @property tax_category tax_category
@@ -36,7 +35,7 @@ class Tax_categories extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Tax_code;
use Config\Services;
/**
* @property tax_code tax_code
@@ -46,7 +45,7 @@ class Tax_codes extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -3,7 +3,6 @@
namespace App\Controllers;
use App\Models\Tax_jurisdiction;
use Config\Services;
/**
* @property tax_jurisdiction tax_jurisdiction
@@ -39,7 +38,7 @@ class Tax_jurisdictions extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

View File

@@ -9,7 +9,6 @@ use App\Models\Tax_category;
use App\Models\Tax_code;
use App\Models\Tax_jurisdiction;
use Config\OSPOS;
use Config\Services;
class Taxes extends Secure_Controller
{
@@ -83,7 +82,7 @@ class Taxes extends Secure_Controller
*/
public function getSearch(): void
{
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
@@ -107,8 +106,7 @@ class Taxes extends Secure_Controller
*/
public function suggest_search(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->tax->get_search_suggestions($search); //TODO: There is no get_search_suggestions function in the tax model
$suggestions = $this->tax->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); //TODO: There is no get_search_suggestions function in the tax model
echo json_encode($suggestions);
}
@@ -120,8 +118,7 @@ class Taxes extends Secure_Controller
*/
public function suggest_tax_categories(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPost('term'));
$suggestions = $this->tax_category->get_tax_category_suggestions($search);
$suggestions = $this->tax_category->get_tax_category_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}
@@ -461,8 +458,7 @@ class Taxes extends Secure_Controller
*/
public function getSuggestTaxCodes(): void
{
$search = Services::htmlPurifier()->purify($this->request->getPostGet('term'));
$suggestions = $this->tax_code->get_tax_codes_search_suggestions($search);
$suggestions = $this->tax_code->get_tax_codes_search_suggestions($this->request->getPostGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
echo json_encode($suggestions);
}