From 02e25280094d8245772acf03396fe31c278ea337 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 4 Apr 2012 15:55:36 -0400 Subject: [PATCH] Fixed some more charset/encoding stuff. --- docs/contrib/replyfilter | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/contrib/replyfilter b/docs/contrib/replyfilter index 193dd40..b74465a 100755 --- a/docs/contrib/replyfilter +++ b/docs/contrib/replyfilter @@ -160,6 +160,11 @@ sub process_text (*$$;$) # if ($encoding eq '7bit' || $encoding eq '8bit') { + # + # Switch the character set to whatever is specified by + # the MIME message + # + binmode($input, ":encoding($charset)"); while (<$input>) { $ret = match_boundary($_, $boundary); if (defined $ret) { @@ -169,6 +174,13 @@ sub process_text (*$$;$) } return 'EOF'; } else { + # + # If we've got some other encoding, the input text is almost + # certainly US-ASCII + # + + binmode($input, ":encoding(us-ascii)"); + $decoder = find_decoder($encoding); if (! defined $decoder) { return 'EOF'; @@ -180,12 +192,14 @@ sub process_text (*$$;$) # to filter it. Read it in; if it's too long, filter it. # + my $chardecode = find_encoding($charset); + while (<$input>) { my $line, $len; last if ($ret = match_boundary($_, $boundary)); - $line = decode($charset, &$decoder($_)); + $line = $chardecode->decode(&$decoder($_)); if (substr($text[$#text], -1, 1) eq "\n") { push @text, $line; -- 1.7.10.4