sanitize

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterCodeFenceMetadata

func FilterCodeFenceMetadata(input string) string

FilterCodeFenceMetadata removes hidden or suspicious info strings from fenced code blocks.

Like FilterInvisibleCharacters this is copy-on-first-match: input whose lines all survive unchanged is returned without allocating.

func FilterHTMLTags

func FilterHTMLTags(input string) string

FilterHTMLTags applies the HTML allowlist policy to input.

func FilterInvisibleCharacters

func FilterInvisibleCharacters(input string) string

FilterInvisibleCharacters removes invisible or control characters that should not appear in user-facing titles or bodies. This includes: - Unicode tag characters: U+E0001, U+E0020–U+E007F - BiDi control characters: U+202A–U+202E, U+2066–U+2069 - BiDi/directional marks: U+200E, U+200F, U+061C - Hidden modifier characters: U+200B, U+200C, U+00AD, U+FEFF, U+180E, U+2060–U+2064 - Orphaned variation selectors: U+FE00–U+FE0F, U+E0100–U+E01EF

Variation selectors are filtered contextually rather than unconditionally. A selector that forms a plausible variation sequence with the character it follows is preserved, so ordinary content such as "✈️", "1️⃣" and CJK ideographic variation sequences survive unchanged. Selectors that cannot belong to such a sequence — those at the start of the input, those following a removed or non-graphic character, and runs of consecutive selectors — are removed, which is the shape used to smuggle hidden payloads.

The scan is copy-on-first-match: clean input is returned unchanged with no allocation.

func Sanitize

func Sanitize(input string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL