Archived
1
0

gay bullshit

This commit is contained in:
Jeff Becker 2017-11-06 19:09:45 -05:00
parent 99a3403ed8
commit 666549e1e4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 25 additions and 19 deletions

View File

@ -7,28 +7,34 @@ import (
type LineWriter struct {
w io.Writer
Left int64
limit int
}
func NewLineWriter(w io.Writer, limit int64) *LineWriter {
func NewLineWriter(w io.Writer, limit int) *LineWriter {
return &LineWriter{
w: w,
Left: limit,
limit: limit,
}
}
func (l *LineWriter) Write(data []byte) (n int, err error) {
if l.Left <= 0 {
err = ErrOversizedMessage
return
}
wr := len(data)
dl := len(data)
data = bytes.Replace(data, []byte{13, 10}, []byte{10}, -1)
n, err = l.w.Write(data)
l.Left -= int64(n)
parts := bytes.Split(data, []byte{10})
for _, part := range parts {
for len(part) > l.limit {
d := make([]byte, l.limit)
copy(d, part[:l.limit])
d = append(d, 10)
_, err = l.w.Write(d)
part = part[l.limit:]
if err != nil {
return n, err
}
n = wr
return
}
}
part = append(part, 10)
_, err = l.w.Write(part)
}
n = dl
return
}

View File

@ -414,7 +414,7 @@ func (self *nntpArticle) WriteBody(wr io.Writer, limit int64) (err error) {
boundary, ok := params["boundary"]
if ok {
nlw := NewLineWriter(wr, limit)
nlw := NewLineWriter(wr, 80)
w := multipart.NewWriter(nlw)
err = w.SetBoundary(boundary)
@ -426,7 +426,7 @@ func (self *nntpArticle) WriteBody(wr io.Writer, limit int64) (err error) {
continue
}
hdr := att.Header()
hdr.Add("Content-Transfer-Encoding", "base64")
hdr.Set("Content-Transfer-Encoding", "base64")
part, err := w.CreatePart(hdr)
if err != nil {
log.Println("failed to create part?", err)
@ -452,7 +452,7 @@ func (self *nntpArticle) WriteBody(wr io.Writer, limit int64) (err error) {
err = w.Close()
w = nil
} else {
nlw := NewLineWriter(wr, limit)
nlw := NewLineWriter(wr, 80)
// write out message
_, err = io.WriteString(nlw, self.message)
}

View File

@ -541,7 +541,7 @@ func read_message_body(body io.Reader, hdr map[string][]string, store ArticleSto
partReader := multipart.NewReader(body, boundary)
for {
part, err := partReader.NextPart()
if err == io.EOF || err == io.ErrUnexpectedEOF {
if part == nil {
callback(nntp)
return nil
} else if err == nil {