Documentation ¶
Index ¶
- type Whitelist
- func (w *Whitelist) AddElement(elementTag string, attributes []string)
- func (w *Whitelist) GetAttributesForElement(elementTag string) []string
- func (w *Whitelist) HasAttributeForElement(elementTag string, attributeName string) bool
- func (w *Whitelist) HasElement(elementTag string) bool
- func (w *Whitelist) SanitizeRemove(reader io.Reader) (string, error)
- func (w *Whitelist) SanitizeRemoveFragment(reader io.Reader) (string, error)
- func (w *Whitelist) SanitizeUnwrap(reader io.Reader) (string, error)
- func (w *Whitelist) SanitizeUnwrapFragment(reader io.Reader) (string, error)
- func (w *Whitelist) ToJSON() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Whitelist ¶
type Whitelist struct { StripWhitespace bool `json:"stripWhitespace"` StripComments bool `json:"stripComments"` Elements map[string][]string `json:"elements"` }
func NewWhitelist ¶
Create a new whitelist from JSON configuration
func WhitelistFromFile ¶
Load a new whitelist from a JSON file
func (*Whitelist) AddElement ¶
func (*Whitelist) GetAttributesForElement ¶
func (*Whitelist) HasAttributeForElement ¶
func (*Whitelist) HasElement ¶
func (*Whitelist) SanitizeRemove ¶
remove non whitelisted elements entirely from a full HTML document
func (*Whitelist) SanitizeRemoveFragment ¶
remove non whitelisted elements in provided document fragment
given the go.net/html library creates a document root with a head and body by default around the provided fragment, simply unwrap those portions along before performing the sanitizeRemove function on the remaining children
func (*Whitelist) SanitizeUnwrap ¶
unwrap non whitelisted elements from a full HTML document
func (*Whitelist) SanitizeUnwrapFragment ¶
unwrap non whitelisted elements in provided document fragment
given the go.net/html library creates a document root with a head and body by default around the provided fragment, simply unwrap those portions along before performing the sanitizeUnwrap function on the remaining children