]> Sergey Matveev's repositories - public-inbox.git/commitdiff
scripts/import_vger_from_mbox: perform mboxrd or mboxo escaping
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 6 Mar 2018 03:51:08 +0000 (03:51 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 6 Mar 2018 04:51:42 +0000 (04:51 +0000)
It appears most of the mboxes in the archive I've been given are
mboxrd (despite having Content-Length:) and needs the escaping.

scripts/import_vger_from_mbox

index 44698870f4f521e2682666a6090a3286bf4ec0f8..6a00fae3fa5ff4414d9dbc2007400c09be606d70 100644 (file)
@@ -11,11 +11,16 @@ use PublicInbox::Import;
 my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
 my $dry_run;
 my $version = 2;
+my $variant = 'mboxrd';
 my %opts = (
        'n|dry-run' => \$dry_run,
        'V|version=i' => \$version,
+       'F|format=s' => \$variant,
 );
 GetOptions(%opts) or die $usage;
+if ($variant ne 'mboxrd' && $variant ne 'mboxo') {
+       die "Unsupported mbox variant: $variant\n";
+}
 my $name = shift or die $usage; # git
 my $email = shift or die $usage; # git@vger.kernel.org
 my $mainrepo = shift or die $usage; # /path/to/v2/repo
@@ -45,6 +50,11 @@ sub do_add ($$) {
        my ($im, $msg) = @_;
        $$msg =~ s/(\r?\n)+\z/$1/s;
        my $mime = PublicInbox::MIME->new($msg);
+       if ($variant eq 'mboxrd') {
+               $$msg =~ s/^>(>*From )/$1/sm;
+       } elsif ($variant eq 'mboxo') {
+               $$msg =~ s/^>From /From /sm;
+       }
        $mime = $vger->scrub($mime);
        return unless $im;
        $im->add($mime) or