📦 NEW: Add package and helper to clean input strings safely

This commit is contained in:
Etienne Marais 2019-04-25 09:12:42 +02:00
parent 24ae64e5bc
commit e50a2962e5
No known key found for this signature in database
GPG Key ID: 5CE3285D17AE9F29
3 changed files with 30 additions and 1 deletions

28
app/Helpers/strings.php Normal file
View File

@ -0,0 +1,28 @@
<?php
if ( ! function_exists('sanitise')) {
/**
* @param string $input
* @return string
*/
function sanitise($input)
{
$clear = clean($input); // Package to remove code "mews/purifier"
$clear = strip_tags($clear);
$clear = html_entity_decode($clear);
$clear = urldecode($clear);
$clear = preg_replace('~[\r\n\t]+~', ' ', trim($clear));
$clear = preg_replace('/ +/', ' ', $clear);
return $clear;
}
/**
* @param string $input
* @return string
*/
function clean_whitespace($input)
{
$clear = preg_replace('~[\r\n\t]+~', ' ', trim($input));
$clear = preg_replace('/ +/', ' ', $clear);
return $clear;
}
}

View File

@ -15,6 +15,7 @@ class HelpersServiceProvider extends ServiceProvider
{
require app_path('Helpers/helpers.php');
require app_path('Helpers/macros.php');
require app_path('Helpers/strings.php');
}
/**

View File

@ -27,7 +27,7 @@
"maatwebsite/excel": "~2.1",
"maxhoffmann/parsedown-laravel": "dev-master",
"mcamara/laravel-localization": "~1.2",
"mews/purifier": "~2.0",
"mews/purifier": "^2.1",
"milon/barcode": "~5.3",
"nitmedia/wkhtml2pdf": "dev-master",
"omnipay/common": "~3",