From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS24940 5.9.0.0/16 X-Spam-Status: No, score=-1.3 required=3.0 tests=AWL,BAYES_00,RCVD_IN_XBL, SPF_FAIL,SPF_HELO_FAIL,URIBL_BLOCKED shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (tor-relay.zwiebeltoralf.de [5.9.158.75]) by dcvr.yhbt.net (Postfix) with ESMTP id DF4881FCBA for ; Sun, 15 May 2016 23:59:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] mbox: consistent header order when decompressed Date: Sun, 15 May 2016 23:59:31 +0000 Message-Id: <20160515235932.18313-2-e@80x24.org> In-Reply-To: <20160515235932.18313-1-e@80x24.org> References: <20160515235932.18313-1-e@80x24.org> List-Id: This should make validating the output easier when testing between different servers. --- lib/PublicInbox/Mbox.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index b81ec0a..efb13e5 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -48,12 +48,16 @@ sub emit_msg { my $base = $feed_opts->{url}; my $mid = mid_clean($header_obj->header('Message-ID')); $mid = uri_escape_utf8($mid); - my %append = ( - 'Archived-At' => "<$base$mid/>", - 'List-Archive' => "<$base>", - 'List-Post' => "{id_addr}>", + my @append = ( + 'Archived-At', "<$base$mid/>", + 'List-Archive', "<$base>", + 'List-Post', "{id_addr}>", ); - while (my ($k, $v) = each %append) { + my $append = ''; + my $crlf = $simple->crlf; + for (my $i = 0; $i < @append; $i += 2) { + my $k = $append[$i]; + my $v = $append[$i + 1]; my @v = $header_obj->header($k); foreach (@v) { if ($v eq $_) { @@ -61,14 +65,14 @@ sub emit_msg { last; } } - $header_obj->header_set($k, @v, $v) if defined $v; + $append .= "$k: $v$crlf" if defined $v; } - my $buf = $header_obj->as_string; unless ($buf =~ /\AFrom /) { $fh->write("From mboxrd\@z Thu Jan 1 00:00:00 1970\n"); } - $fh->write($buf .= $simple->crlf); + $append .= $crlf; + $fh->write($buf .= $append); $buf = $simple->body; $simple->body_set('');