Initial commit
This commit is contained in:
44
vendor/bedrock/functions/sanitize.php
vendored
Normal file
44
vendor/bedrock/functions/sanitize.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* functions/sanitize.php
|
||||
*
|
||||
* This class is used to sanitize user input.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
class Sanitize {
|
||||
/**
|
||||
* This function strips all html tags except for p/a/br from the given string.
|
||||
*
|
||||
* @param {string} [$data] - The string to be parsed
|
||||
* @return {string} - The sanitized string.
|
||||
*/
|
||||
public static function contentShort( $data ) {
|
||||
return strip_tags( $data, '<p><a><br>' );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is to remove $'s and brackets from the rich HTML editor
|
||||
* which are the only parts that cause parse issues
|
||||
*
|
||||
* @param {string} [$data] - The string to be parsed
|
||||
* @return {string} - The sanitized string.
|
||||
*/
|
||||
public static function rich( $data ) {
|
||||
$data = preg_replace( '#\{#', '{', $data );
|
||||
$data = preg_replace( '#\}#', '}', $data );
|
||||
$data = preg_replace( '#\$#', '$', $data );
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function url( $data ) {
|
||||
$trimmed = rtrim( $data, '/' );
|
||||
$filtered = filter_var( $trimmed, FILTER_SANITIZE_URL );
|
||||
return $filtered;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user