emailaddressnormalize

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 2 Imported by: 2

README

Purpose

Provide some level of malformed Email address filtering to protect MTAs.

Validation rules will based on the RFCs but with some additional limitations.

Result Value

There are 3 values in result:

  • checkedEmailAddress: Email address with minimal fixes. In current implementation local part quoting is the only fix.
  • normalizedEmailAddress: Checked email address with normalizations. The normalization including: lower casing, consolidate dots and spaces, remove sub-addressing.
  • err: Validating errors.

Validation Rules

Local Part

  • Dot constraints are ignored: dot can appear at anywhere.
  • Quoted local part is accepted.
  • Space is accepted.
  • Symbols have special meaning in some MTAs is rejected.
    • Including (but not limited to): %, |, !, #, $, *, /, \

Domain Part

  • Option to accept IP literals.
    • Hybrid address (IPv4-mapped IPv6 address) is not accept.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyDomainAfterCheck = errors.New("domain part become empty")

ErrEmptyDomainAfterCheck indicate domain part of given address become empty after check process.

View Source
var ErrEmptyLocalPartAfterCheck = errors.New("local part become empty after check")

ErrEmptyLocalPartAfterCheck indicate local part of given address become empty after check process.

View Source
var ErrEmptyLocalPartAfterNormalize = errors.New("domain part become empty after normalize")

ErrEmptyLocalPartAfterNormalize indicate local part of given address become empty after normalize process.

View Source
var ErrGivenAddressContainSpecialCharacter = errors.New("given email address have special character")

ErrGivenAddressContainSpecialCharacter indicate given email address contain special characters may harmful to MTA.

View Source
var ErrGivenAddressHasIPLiteral = errors.New("given email address has IP literal as domain part")

ErrGivenAddressHasIPLiteral indicate given email address has IP literal as domain part.

View Source
var ErrGivenAddressLocalPartContainI18NCharacter = errors.New("local part of given email address have i18n character")

ErrGivenAddressLocalPartContainI18NCharacter indicate local part of given email address contain international character.

View Source
var ErrGivenAddressNeedQuote = errors.New("given email address have to be quoted")

ErrGivenAddressNeedQuote indicate given email address needs quote.

View Source
var ErrGivenAddressTooShort = errors.New("given email address is too short")

ErrGivenAddressTooShort indicate given email address is too short.

Functions

func NormalizeEmailAddress

func NormalizeEmailAddress(emailAddress string, opt *NormalizeOption) (checkedEmailAddress, normalizedEmailAddress string, err error)

NormalizeEmailAddress normalize given email adderss and return checked and normalized email addresses.

Types

type ErrUnknownDomainCharacterCombination

type ErrUnknownDomainCharacterCombination struct {
	// contains filtered or unexported fields
}

ErrUnknownDomainCharacterCombination indicate unknown mix of characters in domain part.

func (*ErrUnknownDomainCharacterCombination) Error

func (e *ErrUnknownDomainCharacterCombination) Error() (result string)

type NormalizeOption

type NormalizeOption struct {
	AllowQuotedLocalPart             bool
	AllowLocalPartSpecialChars       bool
	AllowLocalPartInternationalChars bool
	AllowIPLiteral                   bool

	RemoveSubAddressingWith SubAddressingCharactersFunc
	RemoveLocalPartDots     bool
}

NormalizeOption contain parameters for normalize function.

type SubAddressingCharactersFunc

type SubAddressingCharactersFunc func(domainPart string) (subAddressChars []rune)

SubAddressingCharactersFunc represent callable return sub-addressing characters of given domain part.

Jump to

Keyboard shortcuts

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