diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-05-12 13:51:48 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-05-12 13:51:48 +0100 |
commit | 5dcbded2d03505d42b27e599e94306f51ba28e64 (patch) | |
tree | b44dc5559c0d877b8c672b07a87c7726929e75c3 /app/models | |
parent | 5e2f00176f73736929fde4e1ab09f594ba5252cf (diff) |
Use mb_chars to prevent slicing multibyte chars under ruby 1.8
mb_chars provides a multibyte-aware wrapper for strings. It should
have no effect on ruby 1.9.3 and above. Although ruby 1.8.7 wouldn't
raise errors on a badly sliced multibyte string, on upgrading to ruby
1.9.3 and above, string operations such as gsub, match and join may
produce ArgumentErrors with the message "invalid byte sequence in UTF-8".
Additionally, a database with 'UTF-8' encoding may produce the error
"PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8""
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 658ee969a..4feee7637 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -654,7 +654,7 @@ class IncomingMessage < ActiveRecord::Base # Save clipped version for snippets if self.cached_attachment_text_clipped.nil? - self.cached_attachment_text_clipped = text[0..MAX_ATTACHMENT_TEXT_CLIPPED] + self.cached_attachment_text_clipped = text.mb_chars[0..MAX_ATTACHMENT_TEXT_CLIPPED] self.save! end |