htmlsafe

package
v1.2.54 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package htmlsafe provides small helpers for producing safe HTML output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(s string) string

Escape escapes untrusted text for safe inclusion into HTML contexts.

func EscapePlainTextHTML added in v1.2.53

func EscapePlainTextHTML(s string) string

EscapePlainTextHTML normalizes untrusted plain text for HTML-by-contract fields.

Some Lesser API fields are rendered as HTML by Mastodon-compatible clients even when the source value is user-authored plain text. Unescape first so legacy already-escaped values do not become double-escaped, then escape the normalized text for safe HTML inclusion.

func RenderTemplate

func RenderTemplate(name string, tmpl string, data any) (string, error)

RenderTemplate renders an html/template to a string.

func SanitizeHTMLByContract

func SanitizeHTMLByContract(content string) string

SanitizeHTMLByContract sanitizes HTML that is meant to be rendered as HTML by clients (e.g. Mastodon fields).

Types

This section is empty.

Jump to

Keyboard shortcuts

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