From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0EDAD6338C4; Wed, 5 Aug 2015 23:29:39 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Cc: Eric Wong Subject: [PATCH] view: pass fallback encoding to enc_for Date: Wed, 5 Aug 2015 23:29:34 +0000 Message-Id: <1438817374-26042-1-git-send-email-e@80x24.org> List-Id: This fixes the fallback to message encoding if the message itself was not UTF-8 --- lib/PublicInbox/View.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index c65e468..934fca6 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -98,7 +98,7 @@ sub index_entry { # account for filter bugs... return if defined $ct && $ct =~ m!\btext/[xh]+tml\b!i; - my $enc = enc_for($ct) || $enc_msg || $enc_utf8; + my $enc = enc_for($ct, $enc_msg); if ($part_nr > 0) { my $fn = $part->filename; @@ -150,8 +150,9 @@ sub index_entry { # only private functions below. sub enc_for { - my ($ct) = @_; - defined $ct or return $enc_utf8; + my ($ct, $default) = @_; + $default ||= $enc_utf8; + defined $ct or return $default; my $ct_parsed = parse_content_type($ct); if ($ct_parsed) { if (my $charset = $ct_parsed->{attributes}->{charset}) { @@ -159,7 +160,7 @@ sub enc_for { return $enc if $enc; } } - $enc_utf8; + $default; } sub multipart_text_as_html { @@ -177,7 +178,7 @@ sub multipart_text_as_html { # account for filter bugs... return if defined $ct && $ct =~ m!\btext/[xh]+tml\b!i; - my $enc = enc_for($ct) || $enc_msg || $enc_utf8; + my $enc = enc_for($ct, $enc_msg); if ($part_nr > 0) { my $fn = $part->filename; -- EW