diff options
Diffstat (limited to 'lib/email')
| -rw-r--r-- | lib/email/body.go | 9 | ||||
| -rw-r--r-- | lib/email/contenttype.go | 10 | ||||
| -rw-r--r-- | lib/email/dkim/func.go | 9 | ||||
| -rw-r--r-- | lib/email/dkim/hashalg.go | 8 | ||||
| -rw-r--r-- | lib/email/dkim/keyflag.go | 8 | ||||
| -rw-r--r-- | lib/email/dkim/signature.go | 14 | ||||
| -rw-r--r-- | lib/email/dkim/tag.go | 10 | ||||
| -rw-r--r-- | lib/email/field.go | 8 | ||||
| -rw-r--r-- | lib/email/is.go | 8 | ||||
| -rw-r--r-- | lib/email/message.go | 2 |
10 files changed, 44 insertions, 42 deletions
diff --git a/lib/email/body.go b/lib/email/body.go index 0dd6dda4..a619a2f7 100644 --- a/lib/email/body.go +++ b/lib/email/body.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package email @@ -195,7 +195,8 @@ func (body *Body) Relaxed() (out []byte) { // Reduce sequence of WSP. end := x hasSpace := 0 - for x = 0; x <= end; x++ { + x = 0 + for ; x <= end; x++ { if body.raw[x] == '\t' || body.raw[x] == ' ' || body.raw[x] == '\n' { hasSpace++ continue diff --git a/lib/email/contenttype.go b/lib/email/contenttype.go index 01f1cc06..8fdbff14 100644 --- a/lib/email/contenttype.go +++ b/lib/email/contenttype.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package email @@ -121,7 +121,7 @@ func isValidToken(tok []byte, quoted bool) bool { if len(tok) == 0 { return false } - for x := 0; x < len(tok); x++ { + for x := range len(tok) { if quoted && tok[x] == ' ' { continue } @@ -164,7 +164,7 @@ func (ct *ContentType) isEqual(other *ContentType) bool { // SetBoundary set or replace the Value for Key "boundary". func (ct *ContentType) SetBoundary(boundary string) { - for x := 0; x < len(ct.Params); x++ { + for x := range len(ct.Params) { if strings.EqualFold(ct.Params[x].Key, ParamNameBoundary) { ct.Params[x].Value = boundary return diff --git a/lib/email/dkim/func.go b/lib/email/dkim/func.go index bd778766..dae52bbe 100644 --- a/lib/email/dkim/func.go +++ b/lib/email/dkim/func.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dkim @@ -17,7 +17,8 @@ func DecodeQP(raw []byte) (out []byte) { out = make([]byte, 0, len(raw)) - for x := 0; x < len(raw); x++ { + var x int + for ; x < len(raw); x++ { if ascii.IsSpace(raw[x]) { continue } diff --git a/lib/email/dkim/hashalg.go b/lib/email/dkim/hashalg.go index 280ab144..b856f82d 100644 --- a/lib/email/dkim/hashalg.go +++ b/lib/email/dkim/hashalg.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dkim @@ -26,7 +26,7 @@ var hashAlgNames = map[HashAlg][]byte{ func unpackHashAlgs(v []byte) (hashAlgs []HashAlg) { algs := bytes.Split(v, sepColon) - for x := 0; x < len(algs); x++ { + for x := range len(algs) { for k, v := range hashAlgNames { if bytes.Equal(v, algs[x]) { hashAlgs = append(hashAlgs, k) diff --git a/lib/email/dkim/keyflag.go b/lib/email/dkim/keyflag.go index a4cd1c44..6e950a6f 100644 --- a/lib/email/dkim/keyflag.go +++ b/lib/email/dkim/keyflag.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dkim @@ -31,7 +31,7 @@ var keyFlagNames = map[KeyFlag]byte{ func unpackKeyFlags(in []byte) (out []KeyFlag) { flags := bytes.Split(in, sepColon) - for x := 0; x < len(flags); x++ { + for x := range len(flags) { if len(flags[x]) != 1 { continue } diff --git a/lib/email/dkim/signature.go b/lib/email/dkim/signature.go index fb155753..6d3129c0 100644 --- a/lib/email/dkim/signature.go +++ b/lib/email/dkim/signature.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dkim @@ -207,7 +207,7 @@ func (sig *Signature) Pack(simple bool) []byte { if len(sig.PresentHeaders) > 0 { bb.WriteString("z=") - for x := 0; x < len(sig.PresentHeaders); x++ { + for x := range len(sig.PresentHeaders) { if x > 0 { bb.WriteByte('|') wrap(bb, simple) @@ -422,7 +422,7 @@ func (sig *Signature) set(t *tag) (err error) { return errEmptyHeader } headers := bytes.Split(t.value, sepColon) - for x := 0; x < len(headers); x++ { + for x := range len(headers) { headers[x] = bytes.ToLower(bytes.TrimSpace(headers[x])) sig.Headers = append(sig.Headers, headers[x]) } @@ -464,7 +464,7 @@ func (sig *Signature) set(t *tag) (err error) { case tagPresentHeaders: z := bytes.Split(t.value, sepVBar) - for x := 0; x < len(z); x++ { + for x := range len(z) { z[x] = bytes.TrimSpace(z[x]) sig.PresentHeaders = append(sig.PresentHeaders, z[x]) } @@ -554,7 +554,7 @@ func (sig *Signature) setQueryMethod(qtype, qopt []byte) (err error) { // validateHeaders validate value of header tag "h=" that it MUST contains // "from". func (sig *Signature) validateHeaders() (err error) { - for x := 0; x < len(sig.Headers); x++ { + for x := range len(sig.Headers) { if bytes.Equal(sig.Headers[x], []byte("from")) { return nil } diff --git a/lib/email/dkim/tag.go b/lib/email/dkim/tag.go index ce1d895d..22931bc8 100644 --- a/lib/email/dkim/tag.go +++ b/lib/email/dkim/tag.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package dkim @@ -94,7 +94,7 @@ func newTag(key []byte) (t *tag, err error) { if !ascii.IsAlpha(key[0]) { return nil, fmt.Errorf("dkim: invalid tag key: '%s'", key) } - for x := 0; x < len(key); x++ { + for x := range len(key) { if ascii.IsAlnum(key[x]) || key[x] == '_' { continue } @@ -126,7 +126,7 @@ func (t *tag) setValue(val []byte) (err error) { if t.key == tagSignature || t.key == tagBodyHash || t.key == tagDNSPublicKey { isBase64 = true } - for x := 0; x < len(val); x++ { + for x := range len(val) { switch { case ascii.IsSpace(val[x]): continue diff --git a/lib/email/field.go b/lib/email/field.go index 77cd9d92..05492548 100644 --- a/lib/email/field.go +++ b/lib/email/field.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package email @@ -219,7 +219,7 @@ func (field *Field) addMailboxes(mailboxes []byte) (err error) { func relaxedName(raw []byte) (rel []byte) { rel = make([]byte, 0, len(raw)) - for x := 0; x < len(raw); x++ { + for x := range len(raw) { if raw[x] == ' ' || raw[x] < 33 || raw[x] > 126 { break } diff --git a/lib/email/is.go b/lib/email/is.go index 6abeb045..b5f2d09b 100644 --- a/lib/email/is.go +++ b/lib/email/is.go @@ -1,6 +1,6 @@ -// Copyright 2019, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. +// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause package email @@ -26,7 +26,7 @@ func IsValidLocal(local []byte) bool { return false } dot := false - for x := 0; x < len(local); x++ { + for x := range len(local) { if local[x] < 33 || local[x] > 126 { return false } diff --git a/lib/email/message.go b/lib/email/message.go index 55ade647..f12d3134 100644 --- a/lib/email/message.go +++ b/lib/email/message.go @@ -448,7 +448,7 @@ func (msg *Message) CanonHeader(subHeader *Header, dkimField *Field) []byte { canonType = dkim.CanonSimple } - for x := 0; x < len(msg.DKIMSignature.Headers); x++ { + for x := range len(msg.DKIMSignature.Headers) { signedField := subHeader.popByName(string(msg.DKIMSignature.Headers[x])) if signedField == nil { continue |
