htmlclean

package module
v0.0.0-...-8cc1d6b Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2015 License: BSD-3-Clause, ISC Imports: 5 Imported by: 0

README

htmlclean

Package htmlclean sanitizes HTML based on a tag and attribute whitelist.

Documentation on Sourcegraph

Build Status status

Attribution

htmlclean was extracted from Matt Jibson's goread, whose license is included in the LICENSE file.

Documentation

Overview

Package htmlclean sanitizes HTML based on a tag and attribute whitelist.

Index

Constants

This section is empty.

Variables

View Source
var AcceptableAttributes = map[string]bool{}/* 114 elements not displayed */

Based on list from MDN's HTML attribute reference https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes

View Source
var AcceptableElements = map[string]bool{

	"noscript": true,

	"section": true,
	"nav":     true,
	"article": true,
	"aside":   true,
	"h1":      true,
	"h2":      true,
	"h3":      true,
	"h4":      true,
	"h5":      true,
	"h6":      true,
	"header":  true,
	"footer":  true,
	"address": true,
	"main":    true,

	"p":          true,
	"hr":         true,
	"pre":        true,
	"blockquote": true,
	"ol":         true,
	"ul":         true,
	"li":         true,
	"dl":         true,
	"dt":         true,
	"dd":         true,
	"figure":     true,
	"figcaption": true,
	"div":        true,

	"a":      true,
	"em":     true,
	"strong": true,
	"small":  true,
	"s":      true,
	"cite":   true,
	"q":      true,
	"dfn":    true,
	"abbr":   true,
	"data":   true,
	"time":   true,
	"code":   true,
	"var":    true,
	"samp":   true,
	"kbd":    true,
	"sub":    true,
	"sup":    true,
	"i":      true,
	"b":      true,
	"u":      true,
	"mark":   true,
	"ruby":   true,
	"rt":     true,
	"rp":     true,
	"bdi":    true,
	"bdo":    true,
	"span":   true,
	"br":     true,
	"wbr":    true,

	"ins": true,
	"del": true,

	"img":    true,
	"iframe": true,
	"embed":  true,
	"object": true,
	"param":  true,
	"video":  true,
	"audio":  true,
	"source": true,
	"track":  true,
	"canvas": true,
	"map":    true,
	"area":   true,
	"svg":    true,
	"math":   true,

	"table":    true,
	"caption":  true,
	"colgroup": true,
	"col":      true,
	"tbody":    true,
	"thead":    true,
	"tfoot":    true,
	"tr":       true,
	"td":       true,
	"th":       true,

	"form":     true,
	"fieldset": true,
	"legend":   true,
	"label":    true,
	"input":    true,
	"button":   true,
	"select":   true,
	"datalist": true,
	"optgroup": true,
	"option":   true,
	"textarea": true,
	"keygen":   true,
	"output":   true,
	"progress": true,
	"meter":    true,
}

Based on list from MDN's HTML5 element list https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list

View Source
var AcceptableURISchemes = map[string]bool{
	"aim":      true,
	"apt":      true,
	"bitcoin":  true,
	"callto":   true,
	"cvs":      true,
	"facetime": true,
	"feed":     true,
	"ftp":      true,
	"git":      true,
	"gopher":   true,
	"gtalk":    true,
	"http":     true,
	"https":    true,
	"imap":     true,
	"irc":      true,
	"itms":     true,
	"jabber":   true,
	"magnet":   true,
	"mailto":   true,
	"mms":      true,
	"msnim":    true,
	"news":     true,
	"nntp":     true,
	"rtmp":     true,
	"rtsp":     true,
	"sftp":     true,
	"skype":    true,
	"svn":      true,
	"ymsgr":    true,
}

Based on list from Wikipedia's URI scheme http://en.wikipedia.org/wiki/URI_scheme

View Source
var UnacceptableElementsWithEndTag = map[string]bool{
	"script": true,
	"applet": true,
	"style":  true,
}

Functions

func Clean

func Clean(s string, u *url.URL) (string, string)

Clean returns the sanitized HTML (based on a tag and attribute whitelist) and the text contents of s. Links are made relative to u, if non-nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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