HeaderSecurity
in package
Provide security tools around HTTP headers to prevent common injection vectors.
Table of Contents
Methods
- assertValid() : void
- Assert a header value is valid.
- assertValidName() : void
- Assert whether or not a header name is valid.
- filter() : string
- Filter a header value
- isValid() : bool
- Validate a header value.
- __construct() : mixed
- Private constructor; non-instantiable.
Methods
assertValid()
Assert a header value is valid.
public
static assertValid(mixed $value) : void
Parameters
- $value : mixed
-
Value to be tested. This method asserts it is a string or number.
Tags
assertValidName()
Assert whether or not a header name is valid.
public
static assertValidName(mixed $name) : void
Parameters
- $name : mixed
Tags
filter()
Filter a header value
public
static filter(string $value) : string
Ensures CRLF header injection vectors are filtered.
Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; header continuations MUST consist of a single CRLF sequence followed by a space or horizontal tab.
This method filters any values not allowed from the string, and is lossy.
Parameters
- $value : string
Tags
Return values
stringisValid()
Validate a header value.
public
static isValid(string|int|float $value) : bool
Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; header continuations MUST consist of a single CRLF sequence followed by a space or horizontal tab.
Parameters
- $value : string|int|float
Tags
Return values
bool__construct()
Private constructor; non-instantiable.
private
__construct() : mixed