Update vendor/

This commit is contained in:
2018-06-28 01:09:56 +01:00
parent 3e5ab5bb0a
commit 21c6e571d8
108 changed files with 121110 additions and 1144 deletions

View File

@@ -19,13 +19,13 @@ type Append struct {
func (cmd *Append) Command() *imap.Command {
var args []interface{}
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
args = append(args, mailbox)
if cmd.Flags != nil {
flags := make([]interface{}, len(cmd.Flags))
for i, flag := range cmd.Flags {
flags[i] = flag
flags[i] = imap.Atom(flag)
}
args = append(args, flags)
}
@@ -37,7 +37,7 @@ func (cmd *Append) Command() *imap.Command {
args = append(args, cmd.Message)
return &imap.Command{
Name: imap.Append,
Name: "APPEND",
Arguments: args,
}
}
@@ -48,9 +48,9 @@ func (cmd *Append) Parse(fields []interface{}) (err error) {
}
// Parse mailbox name
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err = utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err = utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)
@@ -81,11 +81,9 @@ func (cmd *Append) Parse(fields []interface{}) (err error) {
// Parse date
if len(fields) > 0 {
date, ok := fields[0].(string)
if !ok {
if date, ok := fields[0].(string); !ok {
return errors.New("Date must be a string")
}
if cmd.Date, err = time.Parse(imap.DateTimeLayout, date); err != nil {
} else if cmd.Date, err = time.Parse(imap.DateTimeLayout, date); err != nil {
return err
}
}

View File

@@ -27,7 +27,7 @@ type Authenticate struct {
func (cmd *Authenticate) Command() *imap.Command {
return &imap.Command{
Name: imap.Authenticate,
Name: "AUTHENTICATE",
Arguments: []interface{}{cmd.Mechanism},
}
}
@@ -62,7 +62,7 @@ func (cmd *Authenticate) Handle(mechanisms map[string]sasl.Server, conn Authenti
}
encoded := base64.StdEncoding.EncodeToString(challenge)
cont := &imap.ContinuationResp{Info: encoded}
cont := &imap.ContinuationReq{Info: encoded}
if err := conn.WriteResp(cont); err != nil {
return err
}

View File

@@ -9,7 +9,7 @@ type Capability struct{}
func (c *Capability) Command() *imap.Command {
return &imap.Command{
Name: imap.Capability,
Name: "CAPABILITY",
}
}

View File

@@ -9,7 +9,7 @@ type Check struct{}
func (cmd *Check) Command() *imap.Command {
return &imap.Command{
Name: imap.Check,
Name: "CHECK",
}
}

View File

@@ -9,7 +9,7 @@ type Close struct{}
func (cmd *Close) Command() *imap.Command {
return &imap.Command{
Name: imap.Close,
Name: "CLOSE",
}
}

View File

@@ -14,10 +14,10 @@ type Copy struct {
}
func (cmd *Copy) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: imap.Copy,
Name: "COPY",
Arguments: []interface{}{cmd.SeqSet, mailbox},
}
}
@@ -29,15 +29,15 @@ func (cmd *Copy) Parse(fields []interface{}) error {
if seqSet, ok := fields[0].(string); !ok {
return errors.New("Invalid sequence set")
} else if seqSet, err := imap.NewSeqSet(seqSet); err != nil {
} else if seqSet, err := imap.ParseSeqSet(seqSet); err != nil {
return err
} else {
cmd.SeqSet = seqSet
}
if mailbox, ok := fields[1].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[1]); err != nil {
return err
} else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)

View File

@@ -13,10 +13,10 @@ type Create struct {
}
func (cmd *Create) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: imap.Create,
Name: "CREATE",
Arguments: []interface{}{mailbox},
}
}
@@ -26,9 +26,9 @@ func (cmd *Create) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)

View File

@@ -13,10 +13,10 @@ type Delete struct {
}
func (cmd *Delete) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: imap.Delete,
Name: "DELETE",
Arguments: []interface{}{mailbox},
}
}
@@ -26,9 +26,9 @@ func (cmd *Delete) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)

View File

@@ -8,7 +8,7 @@ import (
type Expunge struct{}
func (cmd *Expunge) Command() *imap.Command {
return &imap.Command{Name: imap.Expunge}
return &imap.Command{Name: "EXPUNGE"}
}
func (cmd *Expunge) Parse(fields []interface{}) error {

View File

@@ -10,21 +10,21 @@ import (
// Fetch is a FETCH command, as defined in RFC 3501 section 6.4.5.
type Fetch struct {
SeqSet *imap.SeqSet
Items []string
Items []imap.FetchItem
}
func (cmd *Fetch) Command() *imap.Command {
items := make([]interface{}, len(cmd.Items))
for i, item := range cmd.Items {
if section, err := imap.NewBodySectionName(item); err == nil {
if section, err := imap.ParseBodySectionName(item); err == nil {
items[i] = section
} else {
items[i] = item
items[i] = string(item)
}
}
return &imap.Command{
Name: imap.Fetch,
Name: "FETCH",
Arguments: []interface{}{cmd.SeqSet, items},
}
}
@@ -34,33 +34,22 @@ func (cmd *Fetch) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
seqset, ok := fields[0].(string)
if !ok {
return errors.New("Sequence set must be a string")
}
var err error
if cmd.SeqSet, err = imap.NewSeqSet(seqset); err != nil {
if seqset, ok := fields[0].(string); !ok {
return errors.New("Sequence set must be an atom")
} else if cmd.SeqSet, err = imap.ParseSeqSet(seqset); err != nil {
return err
}
switch items := fields[1].(type) {
case string: // A macro or a single item
switch strings.ToUpper(items) {
case "ALL":
cmd.Items = []string{"FLAGS", "INTERNALDATE", "RFC822.SIZE", "ENVELOPE"}
case "FAST":
cmd.Items = []string{"FLAGS", "INTERNALDATE", "RFC822.SIZE"}
case "FULL":
cmd.Items = []string{"FLAGS", "INTERNALDATE", "RFC822.SIZE", "ENVELOPE", "BODY"}
default:
cmd.Items = []string{strings.ToUpper(items)}
}
cmd.Items = imap.FetchItem(strings.ToUpper(items)).Expand()
case []interface{}: // A list of items
cmd.Items = make([]string, len(items))
for i, v := range items {
item, _ := v.(string)
cmd.Items[i] = strings.ToUpper(item)
cmd.Items = make([]imap.FetchItem, 0, len(items))
for _, v := range items {
itemStr, _ := v.(string)
item := imap.FetchItem(strings.ToUpper(itemStr))
cmd.Items = append(cmd.Items, item.Expand()...)
}
default:
return errors.New("Items must be either a string or a list")

View File

@@ -17,13 +17,14 @@ type List struct {
}
func (cmd *List) Command() *imap.Command {
name := imap.List
name := "LIST"
if cmd.Subscribed {
name = imap.Lsub
name = "LSUB"
}
ref, _ := utf7.Encoder.String(cmd.Reference)
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
enc := utf7.Encoding.NewEncoder()
ref, _ := enc.String(cmd.Reference)
mailbox, _ := enc.String(cmd.Mailbox)
return &imap.Command{
Name: name,
@@ -36,18 +37,20 @@ func (cmd *List) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Reference name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
dec := utf7.Encoding.NewDecoder()
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err := dec.String(mailbox); err != nil {
return err
} else {
// TODO: canonical mailbox path
cmd.Reference = imap.CanonicalMailboxName(mailbox)
}
if mailbox, ok := fields[1].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[1]); err != nil {
return err
} else if mailbox, err := dec.String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)

View File

@@ -14,7 +14,7 @@ type Login struct {
func (cmd *Login) Command() *imap.Command {
return &imap.Command{
Name: imap.Login,
Name: "LOGIN",
Arguments: []interface{}{cmd.Username, cmd.Password},
}
}
@@ -24,12 +24,12 @@ func (cmd *Login) Parse(fields []interface{}) error {
return errors.New("Not enough arguments")
}
var ok bool
if cmd.Username, ok = fields[0].(string); !ok {
return errors.New("Username is not a string")
var err error
if cmd.Username, err = imap.ParseString(fields[0]); err != nil {
return err
}
if cmd.Password, ok = fields[1].(string); !ok {
return errors.New("Password is not a string")
if cmd.Password, err = imap.ParseString(fields[1]); err != nil {
return err
}
return nil

View File

@@ -9,7 +9,7 @@ type Logout struct{}
func (c *Logout) Command() *imap.Command {
return &imap.Command{
Name: imap.Logout,
Name: "LOGOUT",
}
}

View File

@@ -9,7 +9,7 @@ type Noop struct{}
func (c *Noop) Command() *imap.Command {
return &imap.Command{
Name: imap.Noop,
Name: "NOOP",
}
}

View File

@@ -14,11 +14,12 @@ type Rename struct {
}
func (cmd *Rename) Command() *imap.Command {
existingName, _ := utf7.Encoder.String(cmd.Existing)
newName, _ := utf7.Encoder.String(cmd.New)
enc := utf7.Encoding.NewEncoder()
existingName, _ := enc.String(cmd.Existing)
newName, _ := enc.String(cmd.New)
return &imap.Command{
Name: imap.Rename,
Name: "RENAME",
Arguments: []interface{}{existingName, newName},
}
}
@@ -28,17 +29,19 @@ func (cmd *Rename) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if existingName, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if existingName, err := utf7.Decoder.String(existingName); err != nil {
dec := utf7.Encoding.NewDecoder()
if existingName, err := imap.ParseString(fields[0]); err != nil {
return err
} else if existingName, err := dec.String(existingName); err != nil {
return err
} else {
cmd.Existing = imap.CanonicalMailboxName(existingName)
}
if newName, ok := fields[1].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if newName, err := utf7.Decoder.String(newName); err != nil {
if newName, err := imap.ParseString(fields[1]); err != nil {
return err
} else if newName, err := dec.String(newName); err != nil {
return err
} else {
cmd.New = imap.CanonicalMailboxName(newName)

View File

@@ -22,7 +22,7 @@ func (cmd *Search) Command() *imap.Command {
args = append(args, cmd.Criteria.Format()...)
return &imap.Command{
Name: imap.Search,
Name: "SEARCH",
Arguments: args,
}
}

View File

@@ -15,12 +15,12 @@ type Select struct {
}
func (cmd *Select) Command() *imap.Command {
name := imap.Select
name := "SELECT"
if cmd.ReadOnly {
name = imap.Examine
name = "EXAMINE"
}
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: name,
@@ -33,9 +33,9 @@ func (cmd *Select) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)

View File

@@ -9,7 +9,7 @@ type StartTLS struct{}
func (cmd *StartTLS) Command() *imap.Command {
return &imap.Command{
Name: imap.StartTLS,
Name: "STARTTLS",
}
}

View File

@@ -11,19 +11,19 @@ import (
// Status is a STATUS command, as defined in RFC 3501 section 6.3.10.
type Status struct {
Mailbox string
Items []string
Items []imap.StatusItem
}
func (cmd *Status) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
items := make([]interface{}, len(cmd.Items))
for i, f := range cmd.Items {
items[i] = f
for i, item := range cmd.Items {
items[i] = string(item)
}
return &imap.Command{
Name: imap.Status,
Name: "STATUS",
Arguments: []interface{}{mailbox, items},
}
}
@@ -33,21 +33,24 @@ func (cmd *Status) Parse(fields []interface{}) error {
return errors.New("No enough arguments")
}
if mailbox, ok := fields[0].(string); !ok {
return errors.New("Mailbox name must be a string")
} else if mailbox, err := utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
} else {
cmd.Mailbox = imap.CanonicalMailboxName(mailbox)
}
if items, ok := fields[1].([]interface{}); !ok {
return errors.New("Items must be a list")
} else {
cmd.Items = make([]string, len(items))
for i, v := range items {
item, _ := v.(string)
cmd.Items[i] = strings.ToUpper(item)
items, ok := fields[1].([]interface{})
if !ok {
return errors.New("STATUS command parameter is not a list")
}
cmd.Items = make([]imap.StatusItem, len(items))
for i, f := range items {
if s, ok := f.(string); !ok {
return errors.New("Got a non-string field in a STATUS command parameter")
} else {
cmd.Items[i] = imap.StatusItem(strings.ToUpper(s))
}
}

View File

@@ -10,18 +10,18 @@ import (
// Store is a STORE command, as defined in RFC 3501 section 6.4.6.
type Store struct {
SeqSet *imap.SeqSet
Item string
Item imap.StoreItem
Value interface{}
}
func (cmd *Store) Command() *imap.Command {
return &imap.Command{
Name: imap.Store,
Arguments: []interface{}{cmd.SeqSet, cmd.Item, cmd.Value},
Name: "STORE",
Arguments: []interface{}{cmd.SeqSet, string(cmd.Item), cmd.Value},
}
}
func (cmd *Store) Parse(fields []interface{}) (err error) {
func (cmd *Store) Parse(fields []interface{}) error {
if len(fields) < 3 {
return errors.New("No enough arguments")
}
@@ -30,16 +30,18 @@ func (cmd *Store) Parse(fields []interface{}) (err error) {
if !ok {
return errors.New("Invalid sequence set")
}
if cmd.SeqSet, err = imap.NewSeqSet(seqset); err != nil {
var err error
if cmd.SeqSet, err = imap.ParseSeqSet(seqset); err != nil {
return err
}
if cmd.Item, ok = fields[1].(string); !ok {
if item, ok := fields[1].(string); !ok {
return errors.New("Item name must be a string")
} else {
cmd.Item = imap.StoreItem(strings.ToUpper(item))
}
cmd.Item = strings.ToUpper(cmd.Item)
// TODO: could be fields[2:] according to RFC 3501 page 91 "store-att-flags"
cmd.Value = fields[2]
return
return nil
}

View File

@@ -13,29 +13,25 @@ type Subscribe struct {
}
func (cmd *Subscribe) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: imap.Subscribe,
Name: "SUBSCRIBE",
Arguments: []interface{}{mailbox},
}
}
func (cmd *Subscribe) Parse(fields []interface{}) (err error) {
func (cmd *Subscribe) Parse(fields []interface{}) error {
if len(fields) < 0 {
return errors.New("No enogh arguments")
return errors.New("No enough arguments")
}
mailbox, ok := fields[0].(string)
if !ok {
return errors.New("Mailbox name must be a string")
}
if cmd.Mailbox, err = utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if cmd.Mailbox, err = utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
}
return
return nil
}
// An UNSUBSCRIBE command.
@@ -45,27 +41,23 @@ type Unsubscribe struct {
}
func (cmd *Unsubscribe) Command() *imap.Command {
mailbox, _ := utf7.Encoder.String(cmd.Mailbox)
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: imap.Unsubscribe,
Name: "UNSUBSCRIBE",
Arguments: []interface{}{mailbox},
}
}
func (cmd *Unsubscribe) Parse(fields []interface{}) (err error) {
func (cmd *Unsubscribe) Parse(fields []interface{}) error {
if len(fields) < 0 {
return errors.New("No enogh arguments")
}
mailbox, ok := fields[0].(string)
if !ok {
return errors.New("Mailbox name must be a string")
}
if cmd.Mailbox, err = utf7.Decoder.String(mailbox); err != nil {
if mailbox, err := imap.ParseString(fields[0]); err != nil {
return err
} else if cmd.Mailbox, err = utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
}
return
return nil
}

View File

@@ -20,7 +20,7 @@ func (cmd *Uid) Command() *imap.Command {
args = append(args, inner.Arguments...)
return &imap.Command{
Name: imap.Uid,
Name: "UID",
Arguments: args,
}
}