user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] view: pass fallback encoding to enc_for
Date: Wed,  5 Aug 2015 23:29:34 +0000	[thread overview]
Message-ID: <1438817374-26042-1-git-send-email-e@80x24.org> (raw)

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


                 reply	other threads:[~2015-08-05 23:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438817374-26042-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).