asciisanitizer

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package asciisanitizer implements an ASCII control character sanitizer for UTF-8 strings. It will transform ASCII control codes into equivalent inert characters that are safe for display in the terminal. Without sanitization these ASCII control characters will be interpreted by the terminal. This behaviour can be used maliciously as an attack vector, especially the ASCII control characters \x1B and \x9B.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sanitizer

type Sanitizer struct {
	// JSON tells the Sanitizer to replace strings that will be transformed
	// into control characters when the string is marshaled to JSON. Set to
	// true if the string being sanitized represents JSON formatted data.
	JSON bool
	// contains filtered or unexported fields
}

Sanitizer implements transform.Transformer interface.

func (*Sanitizer) Reset

func (t *Sanitizer) Reset()

Reset resets the state and allows the Sanitizer to be reused.

func (*Sanitizer) Transform

func (t *Sanitizer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)

Transform uses a sliding window algorithm to detect C0 and C1 control characters as they are read and replaces them with equivalent inert characters. Bytes that are not part of a control character are not modified.

Jump to

Keyboard shortcuts

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