HumHub Documentation (unofficial)

HTMLPurifier_PercentEncoder
in package

Class that handles operations involving percent-encoding in URIs.

Tags
warning

Be careful when reusing instances of PercentEncoder. The object you use for normalize() SHOULD NOT be used for encode(), or vice-versa.

Table of Contents

Properties

$preserve  : mixed
Reserved characters to preserve when using encode().

Methods

__construct()  : mixed
String of characters that should be preserved while using encode().
encode()  : string
Our replacement for urlencode, it encodes all non-reserved characters, as well as any extra characters that were instructed to be preserved.
normalize()  : string
Fix up percent-encoding by decoding unreserved characters and normalizing.

Properties

$preserve

Reserved characters to preserve when using encode().

protected mixed $preserve = array()
Tags
type

array

Methods

__construct()

String of characters that should be preserved while using encode().

public __construct([bool $preserve = false ]) : mixed
Parameters
$preserve : bool = false

encode()

Our replacement for urlencode, it encodes all non-reserved characters, as well as any extra characters that were instructed to be preserved.

public encode(string $string) : string
Parameters
$string : string

String to be encoded

Tags
note

Assumes that the string has already been normalized, making any and all percent escape sequences valid. Percents will not be re-escaped, regardless of their status in $preserve

Return values
string

Encoded string.

normalize()

Fix up percent-encoding by decoding unreserved characters and normalizing.

public normalize(string $string) : string
Parameters
$string : string

String to normalize

Tags
warning

This function is affected by $preserve, even though the usual desired behavior is for this not to preserve those characters. Be careful when reusing instances of PercentEncoder!

Return values
string

        
On this page

Search results