PHP Class Airship\Engine\Security\Util

Contains various utilities that may be useful in developing Airship cabins.
Exibir arquivo Open project: paragonie/airship Class Usage Examples

Public Methods

Method Description
charWhitelist ( string $input, string $whitelist = self::PRINTABLE_ASCII ) : string Only allow characters present in the whitelist string to pass through the filter.
downloadFileType ( string $mimeType, string $default = 'text/plain', array $badSubstrings = self::DEFAULT_MIME_BLOCK ) : string
noHTML ( string $untrusted ) : string Don't allow any HTML tags or attributes to be inserted into the DOM.
randomString ( integer $length = 64, string $characters = self::PRINTABLE_ASCII ) : string Generate a random string of a given length and character set
stringLength ( string $str ) : integer Binary-safe strlen() implementation
subString ( string $str, integer $start, integer | null $length = null ) : string Binary-safe substr() implementation

Method Details

charWhitelist() public static method

Only allow characters present in the whitelist string to pass through the filter.
public static charWhitelist ( string $input, string $whitelist = self::PRINTABLE_ASCII ) : string
$input string
$whitelist string
return string

downloadFileType() public static method

public static downloadFileType ( string $mimeType, string $default = 'text/plain', array $badSubstrings = self::DEFAULT_MIME_BLOCK ) : string
$mimeType string
$default string
$badSubstrings array
return string

noHTML() public static method

Prevents XSS attacks.
public static noHTML ( string $untrusted ) : string
$untrusted string
return string

randomString() public static method

Generate a random string of a given length and character set
public static randomString ( integer $length = 64, string $characters = self::PRINTABLE_ASCII ) : string
$length integer How many characters do you want?
$characters string Which characters to choose from
return string

stringLength() public static method

Binary-safe strlen() implementation
public static stringLength ( string $str ) : integer
$str string
return integer

subString() public static method

Binary-safe substr() implementation
public static subString ( string $str, integer $start, integer | null $length = null ) : string
$str string
$start integer
$length integer | null
return string