Skip to content

Commit

Permalink
Do not insert a newline as the first character of a header
Browse files Browse the repository at this point in the history
It is closer to Gmail behavior for example.
See #53
  • Loading branch information
alexcesaro committed Mar 30, 2016
1 parent 84856b3 commit bd0e445
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
27 changes: 0 additions & 27 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io/ioutil"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions writeto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down

0 comments on commit bd0e445

Please sign in to comment.