]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
view: note we assume UTF-8 on unknown encodings
[public-inbox.git] / lib / PublicInbox / View.pm
index 91443f55c177bc12d8578a7a4d95a4eae1814333..d897aeecc3ed3abf6ba2dc71bb9540cbf3ec0bdd 100644 (file)
@@ -10,7 +10,8 @@ use bytes (); # only for bytes::length
 use PublicInbox::MsgTime qw(msg_datestamp);
 use PublicInbox::Hval qw(ascii_html obfuscate_addrs prurl mid_href);
 use PublicInbox::Linkify;
-use PublicInbox::MID qw/id_compress mids mids_for_index references/;
+use PublicInbox::MID qw(id_compress mids mids_for_index references
+                       $MID_EXTRACT);
 use PublicInbox::MsgIter;
 use PublicInbox::Address;
 use PublicInbox::WwwStream;
@@ -18,7 +19,7 @@ use PublicInbox::Reply;
 use PublicInbox::ViewDiff qw(flush_diff);
 use POSIX qw(strftime);
 use Time::Local qw(timegm);
-use PublicInbox::SearchMsg qw(subject_normalized);
+use PublicInbox::Smsg qw(subject_normalized);
 use constant COLS => 72;
 use constant INDENT => '  ';
 use constant TCHILD => '` ';
@@ -299,7 +300,7 @@ sub _th_index_lite {
        if (my $smsg = $node->{smsg}) {
                # delete saves about 200KB on a 1K message thread
                if (my $refs = delete $smsg->{references}) {
-                       ($$irt) = ($refs =~ m/<([^>]+)>\z/);
+                       ($$irt) = ($refs =~ m/$MID_EXTRACT\z/o);
                }
        }
        my $irt_map = $mapping->{$$irt} if defined $$irt;
@@ -517,7 +518,9 @@ sub attach_link ($$$$;$) {
        my $rv = $ctx->{obuf};
        $$rv .= qq($nl<a\nhref="$ctx->{mhref}$idx-$sfn">);
        if ($err) {
-               $$rv .= "[-- Warning: decoded text below may be mangled --]\n";
+               $$rv .= <<EOF;
+[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
+EOF
        }
        $$rv .= "[-- Attachment #$idx: ";
        my $ts = "Type: $ct, Size: $size bytes";
@@ -575,7 +578,7 @@ sub add_text_body { # callback for msg_iter
        $s .= "\n" unless $s =~ /\n\z/s;
 
        # split off quoted and unquoted blocks:
-       my @sections = split(/((?:^>[^\n]*\n)+)/sm, $s);
+       my @sections = PublicInbox::MsgIter::split_quotes($s);
        $s = '';
        my $rv = $ctx->{obuf};
        if (defined($fn) || $depth > 0 || $err) {
@@ -1055,7 +1058,7 @@ sub acc_topic { # walk_thread callback
 sub dump_topics {
        my ($ctx) = @_;
        my $order = delete $ctx->{order}; # [ ds, subj1, subj2, subj3, ... ]
-       if (!@$order) {
+       unless ($order) {
                $ctx->{-html_tip} = '<pre>[No topics in range]</pre>';
                return 404;
        }