mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 02:28:15 +03:00
add rfc 4155 about mbox files, and cross-reference in the import/export code for mbox files
This commit is contained in:
parent
a68a9d8a48
commit
88ec5c6fbe
@ -32,6 +32,7 @@ Also see IANA assignments, https://www.iana.org/protocols
|
||||
2231 Yes - MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations
|
||||
3629 - - UTF-8, a transformation format of ISO 10646
|
||||
3676 No - The Text/Plain Format and DelSp Parameters
|
||||
4155 - - The application/mbox Media Type
|
||||
5234 - - Augmented BNF for Syntax Specifications: ABNF
|
||||
5322 Yes - Internet Message Format
|
||||
5598 - - Internet Mail Architecture
|
||||
|
@ -400,6 +400,7 @@ func exportMailbox(log mlog.Log, tx *bstore.Tx, accountDir string, mailboxID int
|
||||
if m.MailFrom != "" {
|
||||
mailfrom = m.MailFrom
|
||||
}
|
||||
// ../rfc/4155:80
|
||||
if _, err := fmt.Fprintf(mboxwriter, "From %s %s\n", mailfrom, m.Received.Format(time.ANSIC)); err != nil {
|
||||
return fmt.Errorf("write message line to mbox temp file: %v", err)
|
||||
}
|
||||
@ -450,6 +451,8 @@ func exportMailbox(log mlog.Log, tx *bstore.Tx, accountDir string, mailboxID int
|
||||
}
|
||||
}
|
||||
|
||||
// ../rfc/4155:365 todo: rewrite messages to be 7-bit. still useful nowadays?
|
||||
|
||||
header := true
|
||||
r := bufio.NewReader(mr)
|
||||
for {
|
||||
@ -458,6 +461,7 @@ func exportMailbox(log mlog.Log, tx *bstore.Tx, accountDir string, mailboxID int
|
||||
return fmt.Errorf("reading message: %v", rerr)
|
||||
}
|
||||
if len(line) > 0 {
|
||||
// ../rfc/4155:354
|
||||
if bytes.HasSuffix(line, []byte("\r\n")) {
|
||||
line = line[:len(line)-1]
|
||||
line[len(line)-1] = '\n'
|
||||
@ -473,6 +477,7 @@ func exportMailbox(log mlog.Log, tx *bstore.Tx, accountDir string, mailboxID int
|
||||
continue
|
||||
}
|
||||
}
|
||||
// ../rfc/4155:119
|
||||
if bytes.HasPrefix(bytes.TrimLeft(line, ">"), []byte("From ")) {
|
||||
if _, err := fmt.Fprint(mboxwriter, ">"); err != nil {
|
||||
return fmt.Errorf("writing escaping >: %v", err)
|
||||
@ -486,6 +491,7 @@ func exportMailbox(log mlog.Log, tx *bstore.Tx, accountDir string, mailboxID int
|
||||
break
|
||||
}
|
||||
}
|
||||
// ../rfc/4155:75
|
||||
if _, err := fmt.Fprint(mboxwriter, "\n"); err != nil {
|
||||
return fmt.Errorf("writing end of message newline: %v", err)
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (mr *MboxReader) Next() (*Message, *os.File, string, error) {
|
||||
}
|
||||
if len(line) > 0 {
|
||||
mr.line++
|
||||
// We store data with crlf, adjust any imported messages with bare newlines.
|
||||
// We store data with crlf, adjust any imported messages with bare newlines. ../rfc/4155:354
|
||||
if !bytes.HasSuffix(line, []byte("\r\n")) {
|
||||
line = append(line[:len(line)-1], "\r\n"...)
|
||||
}
|
||||
@ -156,12 +156,13 @@ func (mr *MboxReader) Next() (*Message, *os.File, string, error) {
|
||||
mr.header = false
|
||||
}
|
||||
|
||||
// Next mail message starts at bare From word.
|
||||
// Next mail message starts at bare From word. ../rfc/4155:71
|
||||
if mr.prevempty && bytes.HasPrefix(line, from) {
|
||||
mr.fromLine = strings.TrimSpace(string(line))
|
||||
mr.header = true
|
||||
break
|
||||
}
|
||||
// ../rfc/4155:119
|
||||
if bytes.HasPrefix(line, []byte(">")) && bytes.HasPrefix(bytes.TrimLeft(line, ">"), []byte("From ")) {
|
||||
line = line[1:]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user