X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=674d7b7cdfb73c77172c59485dea33c60908d3f7;hb=ec1d0105e6f758ced83902b92b25df0c4b75613d;hp=b2f2a7fd5851a404965a6b3ace5ffb8d1c318efc;hpb=d713c17e29976cdb038ad0fa30b229674738abc8;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index b2f2a7fd..674d7b7c 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -4,19 +4,22 @@ package PublicInbox::View; use strict; use warnings; use PublicInbox::Hval; -use URI::Escape qw/uri_escape/; +use URI::Escape qw/uri_escape_utf8/; use Encode qw/find_encoding/; use Encode::MIME::Header; use Email::MIME::ContentType qw/parse_content_type/; + +# TODO: make these constants tunable use constant MAX_INLINE_QUOTED => 5; use constant MAX_TRUNC_LEN => 72; + *ascii_html = *PublicInbox::Hval::ascii_html; my $enc_utf8 = find_encoding('UTF-8'); my $enc_mime = find_encoding('MIME-Header'); # public functions: -sub as_html { +sub msg_html { my ($class, $mime, $full_pfx) = @_; headers_to_html_header($mime, $full_pfx) . @@ -26,10 +29,10 @@ sub as_html { ''; } -sub as_feed_entry { +sub feed_entry { my ($class, $mime, $full_pfx) = @_; - "
" . multipart_text_as_html($mime, $full_pfx) . "
"; + '
' . multipart_text_as_html($mime, $full_pfx) . '
'; } @@ -92,6 +95,7 @@ sub add_text_body_short { my ($enc, $part, $part_nr, $full_pfx) = @_; my $n = 0; my $s = ascii_html($enc->decode($part->body)); + # TODO: fold the "so-and-so wrote:" attribute line here, too: $s =~ s!^((?:(?:>[^\n]*)\n)+)! my $cur = $1; my @lines = split(/\n/, $cur); @@ -210,14 +214,17 @@ sub html_footer { $to ||= $dst; } } + Email::Address->purge_cache; my $subj = $mime->header('Subject') || ''; $subj = "Re: $subj" unless $subj =~ /\bRe:/; - my $irp = uri_escape($mime->header_obj->header_raw('Message-ID') || ''); + my $irp = uri_escape_utf8( + $mime->header_obj->header_raw('Message-ID') || ''); delete $cc{$to}; - $to = uri_escape($to); + $to = uri_escape_utf8($to); + $subj = uri_escape_utf8($subj); - my $cc = uri_escape(join(',', values %cc)); + my $cc = uri_escape_utf8(join(',', values %cc)); my $href = "mailto:$to?In-Reply-To=$irp&Cc=${cc}&Subject=$subj"; 'reply';