nodemailer / mailparser

Decode mime formatted e-mails
Other
1.59k stars 281 forks source link

When `format=flowed` newline characters are lost #114

Closed 5im-0n closed 6 years ago

5im-0n commented 9 years ago

take this mail:

Path: news.fcku.it!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From: Zep Tepi <zepcuccio@gmail.com>
Newsgroups: it.comp.console
Subject: Re: OT devono morire
Date: Thu, 16 Apr 2015 20:45:19 +0200
Organization: Acme INC.
Lines: 10
Message-ID: <mgovu7$gid$1@dont-email.me>
References: <df0ca3a0-26e7-4aec-9013-689c5b4d33e5@googlegroups.com> <a0b27255-0d57-4853-8e84-93ca46c0034d@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 16 Apr 2015 18:44:23 +0000 (UTC)
Injection-Info: mx02.eternal-september.org; posting-host="f645a47764951b3415f25a5d6d8f102c";
        logging-data="16973"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DCiNX7E8TnFv3lEuuqX9n"
X-Newsreader: MesNews/1.08.05.00-it
Cancel-Lock: sha1:NpMSJn7Ry9kTkA7SSn1eq8iRLMI=
X-ICQ: 1931503972
Xref: news.fcku.it it.comp.console:2185

Dopo dura riflessione, Fra ha scritto :
> Fake dio bono
> Guarda il dominio e cerca la stessa news su Google news 

no, vero, confermato dagli stessi vigili del fuoco

-- 
<Satan vien qui subit, I am la morte, I feel patibolo>
<My God is better than your god>
<||Ascolto: Burzum||<===>||Gioco: Motorstorm 3||

feed it to mailparser:

mailparser.on("end", function(mail_object) {
        console.log(JSON.stringify(mail_object));
});

mailparser.write(article);
mailparser.end();

the output is

{
    "text": "Dopo dura riflessione, Fra ha scritto :\n> Fake dio bono\n> Guarda il dominio e cerca la stessa news su Google news no, vero, confermato dagli stessi vigili del fuoco\n\n-- \n<Satan vien qui subit, I am la morte, I feel patibolo>\n<My God is better than your god>\n<||Ascolto: Burzum||<===>||Gioco: Motorstorm 3||\n",
    "headers": {
        "path": "news.fcku.it!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail",
        "from": "Zep Tepi <zepcuccio@gmail.com>",
        "newsgroups": "it.comp.console",
        "subject": "Re: OT devono morire",
        "date": "Thu, 16 Apr 2015 20:45:19 +0200",
        "organization": "Acme INC.",
        "lines": "10",
        "message-id": "<mgovu7$gid$1@dont-email.me>",
        "references": "<df0ca3a0-26e7-4aec-9013-689c5b4d33e5@googlegroups.com> <a0b27255-0d57-4853-8e84-93ca46c0034d@googlegroups.com>",
        "mime-version": "1.0",
        "content-type": "text/plain; charset=\"iso-8859-15\"; format=flowed",
        "content-transfer-encoding": "8bit",
        "injection-date": "Thu, 16 Apr 2015 18:44:23 +0000 (UTC)",
        "injection-info": "mx02.eternal-september.org; posting-host=\"f645a47764951b3415f25a5d6d8f102c\"; logging-data=\"16973\"; mail-complaints-to=\"abuse@eternal-september.org\";\tposting-account=\"U2FsdGVkX1+DCiNX7E8TnFv3lEuuqX9n\"",
        "x-newsreader": "MesNews/1.08.05.00-it",
        "cancel-lock": "sha1:NpMSJn7Ry9kTkA7SSn1eq8iRLMI=",
        "x-icq": "1931503972",
        "xref": "news.fcku.it it.comp.console:2185"
    },
    "subject": "Re: OT devono morire",
    "references": [
        "df0ca3a0-26e7-4aec-9013-689c5b4d33e5@googlegroups.com",
        "a0b27255-0d57-4853-8e84-93ca46c0034d@googlegroups.com"
    ],
    "messageId": "mgovu7$gid$1@dont-email.me",
    "priority": "normal",
    "from": [
        {
            "address": "zepcuccio@gmail.com",
            "name": "Zep Tepi"
        }
    ]
}

but the correct output, imho (and that is how thunderbird shows it too), should be

{
    "text": "Dopo dura riflessione, Fra ha scritto :\n> Fake dio bono\n> Guarda il dominio e cerca la stessa news su Google news \n\nno, vero, confermato dagli stessi vigili del fuoco\n\n-- \n<Satan vien qui subit, I am la morte, I feel patibolo>\n<My God is better than your god>\n<||Ascolto: Burzum||<===>||Gioco: Motorstorm 3||\n",
    "headers": {
        "path": "news.fcku.it!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail",
        "from": "Zep Tepi <zepcuccio@gmail.com>",
        "newsgroups": "it.comp.console",
        "subject": "Re: OT devono morire",
        "date": "Thu, 16 Apr 2015 20:45:19 +0200",
        "organization": "Acme INC.",
        "lines": "10",
        "message-id": "<mgovu7$gid$1@dont-email.me>",
        "references": "<df0ca3a0-26e7-4aec-9013-689c5b4d33e5@googlegroups.com> <a0b27255-0d57-4853-8e84-93ca46c0034d@googlegroups.com>",
        "mime-version": "1.0",
        "sdnsmdncontent-type": "text/plain; charset=\"iso-8859-15\"; format=flowed",
        "content-transfer-encoding": "8bit",
        "injection-date": "Thu, 16 Apr 2015 18:44:23 +0000 (UTC)",
        "injection-info": "mx02.eternal-september.org; posting-host=\"f645a47764951b3415f25a5d6d8f102c\"; logging-data=\"16973\"; mail-complaints-to=\"abuse@eternal-september.org\";\tposting-account=\"U2FsdGVkX1+DCiNX7E8TnFv3lEuuqX9n\"",
        "x-newsreader": "MesNews/1.08.05.00-it",
        "cancel-lock": "sha1:NpMSJn7Ry9kTkA7SSn1eq8iRLMI=",
        "x-icq": "1931503972",
        "xref": "news.fcku.it it.comp.console:2185"
    },
    "subject": "Re: OT devono morire",
    "references": [
        "df0ca3a0-26e7-4aec-9013-689c5b4d33e5@googlegroups.com",
        "a0b27255-0d57-4853-8e84-93ca46c0034d@googlegroups.com"
    ],
    "messageId": "mgovu7$gid$1@dont-email.me",
    "priority": "normal",
    "from": [
        {
            "address": "zepcuccio@gmail.com",
            "name": "Zep Tepi"
        }
    ]
}

some newline characters in the body of the mail are lost.

5im-0n commented 9 years ago

reading a bit and found out that format=flowed should only be a display property for reader applications, it should not change the content of the mail.

http://joeclark.org/ffaq.html