diff options
Diffstat (limited to 'src/mime')
| -rw-r--r-- | src/mime/quotedprintable/reader_test.go | 6 | ||||
| -rw-r--r-- | src/mime/quotedprintable/writer.go | 7 | ||||
| -rw-r--r-- | src/mime/quotedprintable/writer_test.go | 6 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/mime/quotedprintable/reader_test.go b/src/mime/quotedprintable/reader_test.go index 01647840d4..209d6b0793 100644 --- a/src/mime/quotedprintable/reader_test.go +++ b/src/mime/quotedprintable/reader_test.go @@ -66,6 +66,12 @@ func TestReader(t *testing.T) { want: "Now's the time for all folk to come to the aid of their country."}, {in: "accept UTF-8 right quotation mark: ’", want: "accept UTF-8 right quotation mark: ’"}, + + { + // Line break with period at the end. + in: strings.Repeat(".", 75) + "=\r\n=2E\r\n=2E\r\nfooter.", + want: strings.Repeat(".", 76) + "\r\n.\r\nfooter.", + }, } for _, tt := range tests { var buf strings.Builder diff --git a/src/mime/quotedprintable/writer.go b/src/mime/quotedprintable/writer.go index 16ea0bf7d6..0c49e7a28f 100644 --- a/src/mime/quotedprintable/writer.go +++ b/src/mime/quotedprintable/writer.go @@ -133,6 +133,13 @@ func (w *Writer) checkLastByte() error { } b := w.line[w.i-1] + if w.i == 1 && b == '.' { + w.i-- + if err := w.encode(b); err != nil { + return err + } + return nil + } if isWhitespace(b) { w.i-- if err := w.encode(b); err != nil { diff --git a/src/mime/quotedprintable/writer_test.go b/src/mime/quotedprintable/writer_test.go index 07411fe269..b53bb76d5e 100644 --- a/src/mime/quotedprintable/writer_test.go +++ b/src/mime/quotedprintable/writer_test.go @@ -88,6 +88,12 @@ func testWriter(t *testing.T, binary bool) { in: strings.Repeat(" ", 77), want: strings.Repeat(" ", 75) + "=\r\n =20", }, + { + // Line break with period at the end. + in: strings.Repeat(".", 76) + "\n.\nfooter.", + want: strings.Repeat(".", 75) + "=\r\n=2E\r\n=2E\r\nfooter.", + wantB: strings.Repeat(".", 75) + "=\r\n.=0A.=0Afooter.", + }, } for _, tt := range tests { |
