Skip to content

Commit

Permalink
add support for RFC976 From_ lines
Browse files Browse the repository at this point in the history
RFC976 describes these as:

	... the "source path" (normally
	represented in one or more lines at the beginning of the message
	beginning either "From " or ">From ", sometimes called "From_
	lines".)

This fixes an issue where emails generated by cron (on some systems) would have their headers in the mail body.

If the first line starts with "From " or ">From " the line is skipped instead of parsing everything as body.
  • Loading branch information
drscream authored and corecode committed Sep 18, 2019
1 parent 0784c64 commit a2fb617
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
int had_from = 0;
int had_messagid = 0;
int had_date = 0;
int had_first_line = 0;
int had_last_line = 0;
int nocopy = 0;

Expand Down Expand Up @@ -391,6 +392,15 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
line[linelen + 1] = 0;
had_last_line = 1;
}
if (!had_first_line) {
/*
* Ignore a leading RFC-976 From_ or >From_ line mistakenly
* inserted by some programs.
*/
if (strprefixcmp(line, "From ") == 0 || strprefixcmp(line, ">From ") == 0)
continue;
had_first_line = 1;
}
if (!had_headers) {
/*
* Unless this is a continuation, switch of
Expand Down

0 comments on commit a2fb617

Please sign in to comment.