]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/InboxWritable.pm
doc: add technical/whyperl
[public-inbox.git] / lib / PublicInbox / InboxWritable.pm
index e684f5464167d2d25bf15b2dae0998d1d95fe2f7..f2ba21fcbdfa02051d1a5d8677a81279942978f5 100644 (file)
@@ -19,6 +19,7 @@ use constant {
 
 sub new {
        my ($class, $ibx, $creat_opt) = @_;
+       return $ibx if ref($ibx) eq $class;
        my $self = bless $ibx, $class;
 
        # TODO: maybe stop supporting this
@@ -156,12 +157,12 @@ my $from_strict = qr/^From \S+ +\S+ \S+ +\S+ [^:]+:[^:]+:[^:]+ [^:]+/;
 sub mb_add ($$$$) {
        my ($im, $variant, $filter, $msg) = @_;
        $$msg =~ s/(\r?\n)+\z/$1/s;
-       my $mime = PublicInbox::MIME->new($msg);
        if ($variant eq 'mboxrd') {
-               $$msg =~ s/^>(>*From )/$1/sm;
+               $$msg =~ s/^>(>*From )/$1/gms;
        } elsif ($variant eq 'mboxo') {
-               $$msg =~ s/^>From /From /sm;
+               $$msg =~ s/^>From /From /gms;
        }
+       my $mime = PublicInbox::MIME->new($msg);
        if ($filter) {
                my $ret = $filter->scrub($mime) or return;
                return if $ret == REJECT();