Do not insert a newline as the first character of a header

It is closer to Gmail behavior for example.
See #53
This commit is contained in:
Alexandre Cesaro 2016-03-30 19:05:19 +02:00
parent 84856b343c
commit bd0e445b57
2 changed files with 0 additions and 34 deletions

View File

@ -7,7 +7,6 @@ import (
"io/ioutil"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
@ -683,32 +682,6 @@ func mockCopyFileWithHeader(m *Message, name string, h map[string][]string) (str
return name, f, SetHeader(h)
}
func TestLineLength(t *testing.T) {
switch runtime.Version()[:5] {
case "go1.2", "go1.3", "go1.4", "go1.5":
t.Skip("Only pass with Go 1.6+")
}
m := NewMessage()
m.SetAddressHeader("From", "from@example.com", "Señor From")
m.SetHeader("Subject", "{$firstname} Bienvendio a Apostólica, aquí inicia el camino de tu")
m.SetBody("text/plain", strings.Repeat("a", 100))
buf := new(bytes.Buffer)
m.WriteTo(buf)
n := 0
for _, b := range buf.Bytes() {
if b == '\n' {
n = 0
} else {
n++
if n == 80 {
t.Errorf("A line is too long:\n%s", buf.Bytes())
}
}
}
}
func BenchmarkFull(b *testing.B) {
discardFunc := SendFunc(func(from string, to []string, m io.WriterTo) error {
_, err := m.WriteTo(ioutil.Discard)

View File

@ -219,13 +219,6 @@ func (w *messageWriter) writeLine(s string, charsLeft int) string {
}
}
// No space found so insert a newline if it was not the start of the
// line.
if charsLeft != 75 {
w.writeString("\r\n ")
return s
}
// We could not insert a newline cleanly so look for a space or a newline
// even if it is after the limit.
for i := 75; i < len(s); i++ {