Skip to content

Not multipart mime spec compliant: Disallows non-whitespace epilogues #200

@crass

Description

@crass

Here is an example of an email that should be successfully parsed. I believe what ends up happening is that isFinalBoundary never returns true, so the epilogue, the part after the last boundary line, it treated as a part. According to RFC2046 the epilogue should be ignored.

isFinalBoundary, as the comments above the declaration say, only considered the boundary final only if the boundary is followed by whitespace. But the spec allows for non-white space characters after the final boundary line.

// isFinalBoundary reports whether line is the final boundary line
// indicating that all parts are over.
// It matches `^--boundary--[ \t]*(\r\n)?$`
func (mr *MultipartReader) isFinalBoundary(line []byte) bool {
if !bytes.HasPrefix(line, mr.dashBoundaryDash) {
return false
}
rest := line[len(mr.dashBoundaryDash):]
rest = skipLWSPChar(rest)
return len(rest) == 0 || bytes.Equal(rest, mr.nl)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions