encodage forcé seulement en cas de caractères invalides
This commit is contained in:
parent
512f32f8aa
commit
279fb03930
|
@ -42,9 +42,9 @@ class EmailImporter
|
|||
end
|
||||
elsif mail.content_type && mail.content_type.match?(/\btext\/html\b/)
|
||||
plain_text = html_to_text_class.new.convert(mail.decoded)
|
||||
if mail.content_type.match?(/\butf-8\b/)
|
||||
# force utf-8 charset, even if we have to remve invalid characters
|
||||
plain_text.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
||||
|
||||
if mail.content_type.match?(/\butf-8\b/i) and !plain_text.valid_encoding?
|
||||
plain_text.encode('UTF-8', 'binary', invalid: :replace, undef: :replace)
|
||||
else
|
||||
plain_text
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue