validation

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxCredLen     = 255  // Maximum credential length (username/password)
	MaxTokenLen    = 2048 // Maximum bearer token length
	MaxKeyLen      = 256  // Maximum query parameter key length
	MaxValueLen    = 8192 // Maximum query parameter value length
	MaxFilenameLen = 256  // Maximum filename length for uploads

	MaxCookieNameLen   = 256
	MaxCookieValueLen  = 4096
	MaxCookieDomainLen = 255
	MaxCookiePathLen   = 1024

	MaxHeaderKeyLen   = 256
	MaxHeaderValueLen = 8192
)

Common validation constants

Variables

This section is empty.

Functions

func ValidateCookieName

func ValidateCookieName(name string) error

ValidateCookieName validates HTTP cookie names. Prevents cookie injection and enforces RFC 6265 compliance.

func ValidateCookieValue

func ValidateCookieValue(value string) error

ValidateCookieValue validates HTTP cookie values. Prevents cookie injection and enforces RFC 6265 compliance.

func ValidateCredential

func ValidateCredential(cred string, maxLen int, checkColon bool, credType string) error

ValidateCredential validates credentials for Basic Auth. Prevents injection attacks and enforces RFC 7617 (username cannot contain colon).

func ValidateFieldName

func ValidateFieldName(name string, fieldType string) error

ValidateFieldName validates form field names and filenames. Prevents XSS and injection attacks in multipart forms.

func ValidateHeaderKeyValue

func ValidateHeaderKeyValue(key, value string) error

ValidateHeaderKeyValue validates HTTP header keys and values. Prevents header injection and enforces HTTP/1.1 and HTTP/2 compatibility.

func ValidateInputString

func ValidateInputString(input string, maxLen int, name string, additionalChecks func(rune) error) error

ValidateInputString performs common string validation to prevent injection attacks. Checks for control characters, CRLF injection, and length limits. This consolidates validation logic used across multiple components.

func ValidateQueryKey

func ValidateQueryKey(key string) error

ValidateQueryKey validates query parameter keys. Prevents parameter pollution and injection attacks.

func ValidateToken

func ValidateToken(token string) error

ValidateToken validates bearer tokens according to RFC 6750. Prevents header injection and enforces token format rules.

Types

This section is empty.

Jump to

Keyboard shortcuts

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