Back to godoc.org
github.com/luci/luci-go / common / data / text / sanitizehtml

Package sanitizehtml

v0.0.0-...-d4769a7
Latest Go to latest

The latest major version is .

Published: Aug 1, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Overview

Package sanitizehtml implements a sanitizer of a very limited HTML. See Sanitize comment.

Index

func Sanitize

func Sanitize(w io.Writer, r io.Reader) (err error)

Sanitize strips all HTML nodes except allowed ones.

Unless explicitly specified, attributes are stripped. Allowed elements:

- p, br, hr
- h1, h2, h3, h4, h5, h6
- strong, em
- a
  - if href attribute is not a valid absolute HTTP(s) link, it is replaced
    with an innocuous one.
  - alt attribute is allowed
- ul, ol, li
- code, pre

Elements <script> and <style> are ignored entirely. For all other HTML nodes, Sanitize ignores the node, but visits its children.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier