Files
opencloud/vendor/github.com/jhillyerd/enmime/v2/parser.go
Pascal Bleser 63a4470146 test(groupware): add testcontainers based jmap test
* adds pkg/jmap/jmap_integration_test.go

 * uses ghcr.io/stalwartlabs/stalwart:v0.13.2-alpine

 * can be disabled by setting one of the following environment
   variables, in the same fashion as ca0493b28
   - CI=woodpecker
   - CI_SYSTEM_NAME=woodpecker
   - USE_TESTCONTAINERS=false

 * dependencies:
   - bump github.com/go-test/deep from 1.1.0 to 1.1.1
   - add github.com/cention-sany/utf7
   - add github.com/dustinkirkland/golang-petname
   - add github.com/emersion/go-imap/v2
   - add github.com/emersion/go-message
   - add github.com/emersion/go-sasl
   - add github.com/go-crypt/crypt
   - add github.com/go-crypt/x
   - add github.com/gogs/chardet
   - add github.com/inbucket/html2text
   - add github.com/jhilleryerd/enmime/v2
   - add github.com/ssor/bom
   - add gopkg.in/loremipsum.v1
2026-02-10 17:03:59 +01:00

49 lines
1.6 KiB
Go

package enmime
// ReadPartErrorPolicy allows to recover the buffer (or not) on an error when reading a Part content.
//
// See AllowCorruptTextPartErrorPolicy for usage.
type ReadPartErrorPolicy func(*Part, error) bool
// AllowCorruptTextPartErrorPolicy recovers partial content from base64.CorruptInputError when content type is text/plain or text/html.
func AllowCorruptTextPartErrorPolicy(p *Part, err error) bool {
if IsBase64CorruptInputError(err) && (p.ContentType == ctTextHTML || p.ContentType == ctTextPlain) {
return true
}
return false
}
// CustomParseMediaType parses media type. See ParseMediaType for more details
type CustomParseMediaType func(ctype string) (mtype string, params map[string]string, invalidParams []string, err error)
// Parser parses MIME. Create with NewParser to inherit recommended defaults.
type Parser struct {
maxStoredPartErrors int
multipartWOBoundaryAsSinglePart bool
readPartErrorPolicy ReadPartErrorPolicy
skipMalformedParts bool
rawContent bool
customParseMediaType CustomParseMediaType
stripMediaTypeInvalidCharacters bool
disableTextConversion bool
disableCharacterDetection bool
minCharsetDetectRunes int
}
// defaultParser is a Parser with default configuration.
var defaultParser = *NewParser()
// NewParser creates new parser with given options.
func NewParser(ops ...Option) *Parser {
// Construct parser with default options.
p := Parser{
minCharsetDetectRunes: 100,
}
for _, o := range ops {
o.apply(&p)
}
return &p
}