Added ruby 2.3 support (RuntimeError: can't modify frozen String).

This commit is contained in:
Martin Edenhofer 2016-07-18 01:24:53 +02:00
parent e074556d06
commit b6f7858dd5
3 changed files with 7 additions and 7 deletions

View file

@ -15,26 +15,26 @@ module Encode
begin begin
# return if encoding is valid # return if encoding is valid
utf8 = string.force_encoding('UTF-8') utf8 = string.dup.force_encoding('UTF-8')
return utf8 if utf8.valid_encoding? return utf8 if utf8.valid_encoding?
# try to encode from Windows-1252 to utf8 # try to encode from Windows-1252 to utf8
string.encode!( 'UTF-8', 'Windows-1252' ) string.encode!('UTF-8', 'Windows-1252')
rescue EncodingError => e rescue EncodingError => e
Rails.logger.error "Bad encoding: #{string.inspect}" Rails.logger.error "Bad encoding: #{string.inspect}"
string = string.encode!( 'UTF-8', invalid: :replace, undef: :replace, replace: '?' ) string = string.encode!('UTF-8', invalid: :replace, undef: :replace, replace: '?')
end end
return string return string
end end
# convert string # convert string
begin begin
string.encode!( 'UTF-8', charset ) string.encode!('UTF-8', charset)
rescue => e rescue => e
Rails.logger.error 'ERROR: ' + e.inspect Rails.logger.error 'ERROR: ' + e.inspect
string string
end end
#Iconv.conv( 'UTF8', charset, string ) #Iconv.conv( 'UTF8', charset, string)
end end
end end

View file

@ -342,7 +342,7 @@ Liebe Grüße!
}, },
{ {
data: IO.binread('test/fixtures/mail21.box'), data: IO.binread('test/fixtures/mail21.box'),
body_md5: 'ca181b534e98acc7674a70e8497e9791', body_md5: 'f7de1c4d9f266a85897b6e8b9403d62d',
params: { params: {
from: 'Viagra Super Force Online <pharmacy_affordable1@ertelecom.ru>', from: 'Viagra Super Force Online <pharmacy_affordable1@ertelecom.ru>',
from_email: 'pharmacy_affordable1@ertelecom.ru', from_email: 'pharmacy_affordable1@ertelecom.ru',

File diff suppressed because one or more lines are too long