user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] view: pass fallback encoding to enc_for
@ 2015-08-05 23:29 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-05 23:29 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-05 23:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-05 23:29 [PATCH] view: pass fallback encoding to enc_for Eric Wong

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).