my ($arg, $link, $reply_to_all) =
PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+ if (ref($arg) eq 'SCALAR') {
+ return '<pre id=R>'.ascii_html($$arg).'</pre>';
+ }
# mailto: link only works if address obfuscation is disabled
if ($link) {
$rv .= $subj . "\n";
$rv .= _th_index_lite($mid_raw, \$irt, $id, $ctx);
my @tocc;
- my $mime = $smsg->{mime};
+ my $ds = $smsg->ds; # for v1 non-Xapian/SQLite users
+ # deleting {mime} is critical to memory use,
+ # the rest of the fields saves about 400K as we iterate across 1K msgs
+ my ($mime) = delete @$smsg{qw(mime ds ts blob subject)};
+
my $hdr = $mime->header_obj;
my $from = _hdr_names_html($hdr, 'From');
obfuscate_addrs($obfs_ibx, $from) if $obfs_ibx;
- $rv .= "From: $from @ ".fmt_ts($smsg->ds)." UTC";
+ $rv .= "From: $from @ ".fmt_ts($ds)." UTC";
my $upfx = $ctx->{-upfx};
my $mhref = $upfx . mid_escape($mid_raw) . '/';
$rv .= qq{ (<a\nhref="$mhref">permalink</a> / };
my $nr_s = 0;
my $siblings;
if (my $smsg = $node->{smsg}) {
- ($$irt) = (($smsg->{references} || '') =~ m/<([^>]+)>\z/);
+ # delete saves about 200KB on a 1K message thread
+ if (my $refs = delete $smsg->{references}) {
+ ($$irt) = ($refs =~ m/<([^>]+)>\z/);
+ }
}
my $irt_map = $mapping->{$$irt} if defined $$irt;
if (defined $irt_map) {
my ($part, $depth) = @$p; # attachment @idx is unused
my $ct = $part->content_type || 'text/plain';
my $fn = $part->filename;
+ my ($s, $err) = msg_part_text($part, $ct);
- if ($ct =~ m!\btext/x?html\b!i) {
- return attach_link($upfx, $ct, $p, $fn);
- }
-
- my $s = eval { $part->body_str };
-
- # badly-encoded message? tell the world about it!
- my $err = $@;
- if ($err) {
- if ($ct =~ m!\btext/plain\b!i) {
- # Try to assume UTF-8 because Alpine seems to
- # do wacky things and set charset=X-UNKNOWN
- $part->charset_set('UTF-8');
- $s = eval { $part->body_str };
-
- # If forcing charset=UTF-8 failed,
- # attach_link will warn further down...
- $s = $part->body if $@;
- } else {
- return attach_link($upfx, $ct, $p, $fn);
- }
- }
+ return attach_link($upfx, $ct, $p, $fn) unless defined $s;
my @lines = split(/^/m, $s);
$s = '';
if (defined($fn) || $depth > 0 || $err) {
+ # badly-encoded message with $err? tell the world about it!
$s .= attach_link($upfx, $ct, $p, $fn, $err);
$s .= "\n";
}