On Thu, Dec 7, 2017 at 12:02 AM, Nathan Payre
<[email protected]> wrote:
> +sub parse_header_line {
> + my $lines = shift;
> + my $parsed_line = shift;
> +
> + foreach (split(/\n/, $lines)) {
> + if (/^(To|Cc|Bcc):\s*(.+)$/i) {
> + $parsed_line->{lc $1} = [ parse_address_line($2) ];
> + } elsif
> (/^(From|Subject|Date|In-Reply-To|Message-ID|MIME-Version|Content-Type|Content-Transfer-Encoding|References):\s*(.+)\s*$/i)
> {
> + $parsed_line->{lc $1} = $2;
> + }
> + }
> +}
Nit: As noted in my earlier review this results in very long lines,
I'm just typing this pseudocode into an E-Mail client so not tested at
all, but this would be better:
my $header_parsed = join "|", qw(To Cc Bcc);
my $header_unparsed = join "|", qw(From Subject Message-ID ...); #
line wrap this at some point
foreach [...]
if (/^($header_parsed)[...]
} elsif (^/($header_unparsed)[...].