aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/CHANGELOG2
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/quoting.rb5
-rw-r--r--actionmailer/test/fixtures/raw_email620
-rwxr-xr-xactionmailer/test/mail_service_test.rb6
4 files changed, 33 insertions, 0 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index 3a7a511916..b884272feb 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Silently ignore Iconv::IllegalSequence errors when converting text #1341 [lon@speedymac.com]
+
* Support attachments and multipart messages.
* Added new accessors for the various mail properties.
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
index 6494b592d6..43e834b2a6 100644
--- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
@@ -72,6 +72,11 @@ module TMail
def convert_to(text, to, from)
return text unless to && from
text ? Iconv.iconv(to, from, text).first : ""
+ rescue Iconv::IllegalSequence
+ # the 'from' parameter specifies a charset other than what the text
+ # actually is...not much we can do in this case but just return the
+ # unconverted text.
+ text
end
rescue LoadError
# Not providing quoting support
diff --git a/actionmailer/test/fixtures/raw_email6 b/actionmailer/test/fixtures/raw_email6
new file mode 100644
index 0000000000..93289c4f92
--- /dev/null
+++ b/actionmailer/test/fixtures/raw_email6
@@ -0,0 +1,20 @@
+Return-Path: <xxx@xxxx.xxx>
+Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id C1B953B4CB6 for <xxxxx@Exxx.xxxx.xxx>; Tue, 10 May 2005 15:27:05 -0500
+Received: from SMS-GTYxxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id ca for <xxxxx@Exxx.xxxx.xxx>; Tue, 10 May 2005 15:27:04 -0500
+Received: from xxx.xxxx.xxx by SMS-GTYxxx.xxxx.xxx with ESMTP id j4AKR3r23323 for <xxxxx@Exxx.xxxx.xxx>; Tue, 10 May 2005 15:27:03 -0500
+Date: Tue, 10 May 2005 15:27:03 -0500
+From: xxx@xxxx.xxx
+Sender: xxx@xxxx.xxx
+To: xxxxxxxxxxx@xxxx.xxxx.xxx
+Message-Id: <xxx@xxxx.xxx>
+X-Original-To: xxxxxxxxxxx@xxxx.xxxx.xxx
+Delivered-To: xxx@xxxx.xxx
+Importance: normal
+Content-Type: text/plain; charset=us-ascii
+
+Test test. Hi. Waving. m
+
+----------------------------------------------------------------
+Sent via Bell Mobility's Text Messaging service.
+Envoyé par le service de messagerie texte de Bell Mobilité.
+----------------------------------------------------------------
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 861206fc54..d715b88b10 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -425,6 +425,12 @@ EOF
assert_nothing_raised { mail.body }
end
+ def test_decode_message_with_incorrect_charset
+ fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email6")
+ mail = TMail::Mail.parse(fixture)
+ assert_nothing_raised { mail.body }
+ end
+
def test_explicitly_multipart_messages
mail = TestMailer.create_explicitly_multipart_example(@recipient)
assert_equal 3, mail.parts.length