[PATCH v2] Let mailsplit and mailinfo handle mails with CRLF line-endings
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Aug 4, 2009, 21:03 UTC
- Message-ID
- <20090804210327.GA23747@blimp.localdomain>
- In-Reply-To
- <20090804172638.GA15136@blimp.localdomain>
Noticed by H. Peter Anvin.
It is not that uncommon to have mails with DOS line-ending, notably Thunderbird and web mailers like Gmail (when saving what they call "original" message).
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> ---
Corrected bug with unconditonal last (or very long) line shortening if it contains a CR in next-to-last character. Noticed by Sverre Rabbelier.
It should also handle the case mentioned by Brandon Casey.
builtin-mailsplit.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c index ad5f6b5..48285a0 100644 --- a/builtin-mailsplit.c +++ b/builtin-mailsplit.c @@ -58,6 +58,8 @@ int read_line_with_nul(char *buf, int size, FILE *in) if (c == '\n' || len + 1 >= size) break; } + if (c == '\n' && len > 1 && buf[len - 2] == '\r') + buf[--len - 1] = '\n'; buf[len] = '\0'; return len;
-- 1.6.4.34.gc3135e