Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug of issue #38 #39

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed bug #38
casatwy committed Jun 8, 2019
commit 9601071e79a09876452d3e1ff79c7b14e6cb196d
8 changes: 6 additions & 2 deletions textproto/header.go
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ func (fs *headerFields) index() int {
if fs.cur >= len(fs.h.l) {
panic("message: HeaderFields method called after Next returned false")
}
return len(fs.h.l)-fs.cur-1
return len(fs.h.l) - fs.cur - 1
}

func (fs *headerFields) field() *headerField {
@@ -213,7 +213,7 @@ func (fs *headerFieldsByKey) index() int {
if fs.cur >= len(fs.h.m[fs.k]) {
panic("message: headerfields.key or value called after next returned false")
}
return len(fs.h.m[fs.k])-fs.cur-1
return len(fs.h.m[fs.k]) - fs.cur - 1
}

func (fs *headerFieldsByKey) field() *headerField {
@@ -392,6 +392,10 @@ func ReadHeader(r *bufio.Reader) (Header, error) {

for {
kv, err := readContinuedLineSlice(r)

kv = bytes.ReplaceAll(kv, []byte("\r"), []byte(""))
kv = bytes.ReplaceAll(kv, []byte("\n"), []byte(""))

if len(kv) == 0 {
return newHeader(fs), err
}