parser

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2016 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Overview

Package parser parses and verifies user-sent post data

Index

Constants

View Source
const (

	// MaxLengthBody is the maximum allowed length of a post text body
	MaxLengthBody = 2000
)

Variables

View Source
var (
	// CommandRegexp matches any hash command in a line
	CommandRegexp = regexp.MustCompile(`^#(flip|\d*d\d+|8ball|pyu|pcount)$`)

	// ErrBodyTooLong is returned, when a post text body has exceeded
	// MaxLengthBody
	ErrBodyTooLong = ErrTooLong("post body")
)

Functions

func FormatEmail

func FormatEmail(email string) string

FormatEmail validates and checks

func ParseLine

func ParseLine(line []byte, board string) (
	links types.LinkMap, command types.Command, err error,
)

ParseLine parses a full text line of a post

func ParseName

func ParseName(name string) (string, string, error)

ParseName parses the name field into a name and tripcode, if any

func ParseSubject

func ParseSubject(s string) (string, error)

ParseSubject verifies and trims a thread subject string

func VerifyPostPassword

func VerifyPostPassword(s string) error

VerifyPostPassword verifies a post password exists does not surpass the maximum allowed length

Types

type ErrTooLong

type ErrTooLong string

ErrTooLong is passed, when a field exceeds the maximum string length for that specific field

func (ErrTooLong) Error

func (e ErrTooLong) Error() string

Jump to

Keyboard shortcuts

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