aboutsummaryrefslogtreecommitdiff
path: root/pkg/rfc822/writer.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/rfc822/writer.go (renamed from pkg/util/fixWriter.go)23
1 files changed, 16 insertions, 7 deletions
diff --git a/pkg/util/fixWriter.go b/pkg/rfc822/writer.go
index d78b618..07751ea 100644
--- a/pkg/util/fixWriter.go
+++ b/pkg/rfc822/writer.go
@@ -1,15 +1,25 @@
-package util
+// Package rfc822 provides a writer that ensures the intrinsics of RFC 822.
+//
+// Rationale
+//
+// Cyrus IMAP really cares about the hard specifics of RFC 822, namely not allowing single \r and \n.
+//
+// See also: https://www.cyrusimap.org/imap/reference/faqs/interop-barenewlines.html
+// and: https://github.com/Necoro/feed2imap-go/issues/46
+//
+// NB: This package currently only cares about the newlines.
+package rfc822
import "io"
-type fixWriter struct {
+type rfc822Writer struct {
w io.Writer
}
var lf = []byte{'\n'}
var cr = []byte{'\r'}
-func (f fixWriter) Write(p []byte) (n int, err error) {
+func (f rfc822Writer) Write(p []byte) (n int, err error) {
crFound := false
start := 0
@@ -56,8 +66,7 @@ func (f fixWriter) Write(p []byte) (n int, err error) {
return
}
-// Cyrus IMAP really cares about single \r and \n.
-// Implement this fixer to change them into \r\n.
-func FixWriter(w io.Writer) io.Writer {
- return fixWriter{w}
+// Writer creates a new RFC 822 conform writer.
+func Writer(w io.Writer) io.Writer {
+ return rfc822Writer{w}
}
e200de2c506c40d1f2c3152471b1b11d58c4f6f&follow=1'>Use this wrapper instead of ctypes to set the textdomain and stuff for the gt...René 'Necoro' Neumann1-9/+5 2009-09-03Add small wrapper to C-gettextRené 'Necoro' Neumann2-1/+22 2009-08-31Update messages.potRené 'Necoro' Neumann1-42/+94 2009-08-31Removed the gtk- strings from translationsRené 'Necoro' Neumann7-3639/+3479 2009-08-31Removed the 'translatable' attribute from 'gtk-*' stringsRené 'Necoro' Neumann5-11/+11 2009-08-31Removed TODO. Renamed ChangeLog to TODORené 'Necoro' Neumann2-40/+0 2009-08-27Only import stuff if necessaryRené 'Necoro' Neumann1-8/+8 2009-08-25Release the threadQueue-Lock in syncv0.13René 'Necoro' Neumann1-0/+1 2009-08-25Updated portugese translationAlberto Federman Neto1-650/+687 2009-08-15Update spanish translationDaniel Halens1-245/+258 2009-08-15Use boolean flags instead of obscure C flags for ipc.MessageQueueRené 'Necoro' Neumann3-13/+15 2009-08-15TypoRené 'Necoro' Neumann1-1/+1 2009-08-15Enhanced the extensions.shRené 'Necoro' Neumann1-3/+8 2009-08-15Move eix-format to correct locationRené 'Necoro' Neumann1-0/+0