Sanitize
class Sanitize (View source)
This class includes various sanitization methods that can be called statically
Methods
Checks whether given link is valid
Sanitizes $message, taking into account our special codes for formatting.
Sanitize a filename by removing anything besides legit characters
Formats an javascript assignment with proper escaping of a value and support for assigning array of strings.
Removes all variables from request except allowed ones.
Details
static bool
checkLink(string $url, bool $http = false, bool $other = false)
Checks whether given link is valid
static string
convertBBCode(string $message, bool $safe = false)
Sanitizes $message, taking into account our special codes for formatting.
static string
sanitizeFilename(string $filename, bool $replaceDots = false)
Sanitize a filename by removing anything besides legit characters
Intended usecase: When using a filename in a Content-Disposition header the value should not contain ; or "
When exporting, avoiding generation of an unexpected double-extension file
static string
getJsValue(string $key, mixed $value)
Formats an javascript assignment with proper escaping of a value and support for assigning array of strings.
static void
removeRequestVars(array $allowList)
Removes all variables from request except allowed ones.