validator

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package validator provides HTML validation and security checking for user content.

This package validates HTML content to ensure it's safe to store and display. It checks for:

  • Script tags that could execute arbitrary JavaScript
  • Event handler attributes (onclick, onload, etc.)
  • Shadow DOM usage (marked by omnomshadowroot attribute)

The validator is used when importing bookmarks or snapshots to prevent XSS attacks and other security issues. It parses HTML using golang.org/x/net/html and reports any security concerns.

Example usage:

result := validator.ValidateHTML(htmlContent)
if result.Error != nil {
    log.Printf("Invalid HTML: %v", result.Error)
    return
}
if result.HasShadowDOM {
    log.Println("Content uses Shadow DOM")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result added in v0.4.0

type Result struct {
	Error         error
	HasShadowDOM  bool
	HasMultimedia bool
}

Result contains HTML validation results.

func ValidateHTML

func ValidateHTML(h []byte) Result

ValidateHTML validates HTML content for security issues.

Jump to

Keyboard shortcuts

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