API / Minn\Support / KsesPolicy

KsesPolicy final readonly class

Minn\Support\KsesPolicy · public/minn/src/Minn/Support/KsesPolicy.php · 115 lines

What one kses pass allows: the tags, each tag's attributes (allowed plainly or with value rules), whether a tag takes data- attributes, which attributes hold URIs, and the schemes those URIs may use.

Constants and properties

privatereadonly array $tags

Promoted from the constructor.

privatereadonly array $prefixes

Promoted from the constructor.

privatereadonly array $uriAttributes

Promoted from the constructor.

propreadonly array $schemes

Promoted from the constructor.

Public

new__construct(array $tags, array $prefixes, array $uriAttributes, array $schemes)#
$tagsarray<string, array<string, mixed>>tag => attribute => true, or a list of value rules
$prefixesarray<string, list<string>>tag => attribute-name prefixes it accepts (only "data-")
$uriAttributeslist<string>
$schemeslist<string>
staticpost(): self#

Post content from an author without unfiltered_html: the reference's post allowlist as captured.

staticcomment(): self#

Comments, profiles and term descriptions: only the attributes each tag lists, nothing global.

staticfromAllowlist(array $allowedHtml, array $schemes, array $uriAttributes): self#

A caller's own allowlist taken literally: a listed attribute is allowed whatever it maps to (false included, as the reference only asks whether the name is there), an array carries value rules, and "data-*" lets the tag take any data- name. Nothing else is implied.

$allowedHtmlarray<array-key, mixed>
$schemeslist<string>
$uriAttributeslist<string>
methodallowsTag(string $tag): bool#

Whether the tag may appear at all.

methodrules(string $tag, string $name): ?array#

The rules an attribute carries on a tag: an empty list when it is allowed plainly, null when it is not allowed.

@return array<array-key, mixed>|null
methodrequired(string $tag): array#

The attributes a tag must keep: lose one and the tag keeps none.

@return list<string>
methodholdsUri(string $name): bool#

Whether the attribute holds a URI whose scheme must be judged.