diff options
author | Rowan Crawford <wombleton@gmail.com> | 2014-02-23 18:09:35 +1300 |
---|---|---|
committer | Rowan Crawford <wombleton@gmail.com> | 2014-02-23 18:09:35 +1300 |
commit | 71deb85e4460d255e04741e6d1e2850f9ace1fd5 (patch) | |
tree | c98a49fa4e9b0054464c5d53eefac72d2253b5bf /app/models/incoming_message.rb | |
parent | efea8f2aa0ac36e83b15f3a56f9f243467f8225b (diff) |
Add test for _get_attachment_text_internal with invalid utf-8
Diffstat (limited to 'app/models/incoming_message.rb')
-rw-r--r-- | app/models/incoming_message.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 32123ae49..52f28a3fd 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -792,15 +792,17 @@ class IncomingMessage < ActiveRecord::Base return self.cached_attachment_text_clipped end - def _get_attachment_text_internal + def _extract_text # Extract text from each attachment - text = '' - attachments = self.get_attachments_for_display - for attachment in attachments - text += MailHandler.get_attachment_text_one_file(attachment.content_type, + self.get_attachments_for_display.reduce(''){ |memo, attachment| + memo += MailHandler.get_attachment_text_one_file(attachment.content_type, attachment.body, attachment.charset) - end + } + end + + def _get_attachment_text_internal + text = self._extract_text # Remove any bad characters if String.method_defined?(:encode) @@ -812,7 +814,6 @@ class IncomingMessage < ActiveRecord::Base end end - # Returns text for indexing def get_text_for_indexing_full return get_body_for_quoting + "\n\n" + get_attachment_text_full |