Skip to content

Commit

Permalink
chore!: remove deprecated ParseMediaType (#352)
Browse files Browse the repository at this point in the history
Signed-off-by: James Hillyerd <james@hillyerd.com>
  • Loading branch information
jhillyerd authored Sep 7, 2024
1 parent 205ac32 commit e563ba5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
21 changes: 0 additions & 21 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/jhillyerd/enmime/v2/internal/coding"
"github.com/jhillyerd/enmime/v2/internal/stringutil"
inttp "github.com/jhillyerd/enmime/v2/internal/textproto"
"github.com/jhillyerd/enmime/v2/mediatype"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -101,26 +100,6 @@ func ParseAddressList(list string) ([]*mail.Address, error) {
return ret, nil
}

// Terminology from RFC 2047:
// encoded-word: the entire =?charset?encoding?encoded-text?= string
// charset: the character set portion of the encoded word
// encoding: the character encoding type used for the encoded-text
// encoded-text: the text we are decoding

// ParseMediaType is a more tolerant implementation of Go's mime.ParseMediaType function.
//
// Tolerances accounted for:
// - Missing ';' between content-type and media parameters
// - Repeating media parameters
// - Unquoted values in media parameters containing 'tspecials' characters
//
// Deprecated: Use mediaType.Parse instead
func ParseMediaType(ctype string) (mtype string, params map[string]string, invalidParams []string,
err error) {
// Export of internal function.
return mediatype.Parse(ctype)
}

// ReadHeader reads a block of SMTP or MIME headers and returns a
// textproto.MIMEHeader. Header parse warnings & errors will be added to
// ErrorCollector, io errors will be returned directly.
Expand Down
6 changes: 4 additions & 2 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"strings"
"testing"

"github.com/jhillyerd/enmime/v2/mediatype"
)

func TestSetCustomParseMediaType(t *testing.T) {
Expand All @@ -12,7 +14,7 @@ func TestSetCustomParseMediaType(t *testing.T) {
}
changeAndUtilizeDefault := func(ctype string) (mtype string, params map[string]string, invalidParams []string, err error) {
modifiedStr := strings.ReplaceAll(ctype, "application/Pamir Viewer", "application/PamirViewer")
return ParseMediaType(modifiedStr)
return mediatype.Parse(modifiedStr)
}
tcases := []struct {
ctype string
Expand Down Expand Up @@ -57,7 +59,7 @@ func ExampleSetCustomParseMediaType() {
replaceSpecificContentType := func(ctype string) (mtype string, params map[string]string, invalidParams []string, err error) {
modifiedStr := strings.ReplaceAll(ctype, "application/Pamir Viewer", "application/PamirViewer")

return ParseMediaType(modifiedStr)
return mediatype.Parse(modifiedStr)
}

invalidMessageContent := `From: <enmime@parser.git>
Expand Down

0 comments on commit e563ba5

Please sign in to comment.