Fixed issue #2722 - mail processing impossible: invalid byte sequence in UTF-8.

This commit is contained in:
Martin Edenhofer 2019-08-29 18:05:17 +02:00
parent d57ac5338e
commit 7f1d30e089
2 changed files with 14 additions and 0 deletions

View file

@ -284,6 +284,7 @@ class String
chr_orig
end
end
string = string.utf8_encode(fallback: :read_as_sanitized_binary)
# remove tailing empty spaces
string.gsub!(/[[:blank:]]+$/, '')

View file

@ -542,6 +542,18 @@ RSpec.describe String do
TEXT
end
context 'html encoding' do
it 'converts Ä in Ä' do
expect('<div>test something.&Auml;</div>'.html2text)
.to eq('test something.Ä')
end
it 'strips invalid html encoding chars' do
expect('<div>test something.&#55357;</div>'.html2text)
.to eq('test something.í ˝')
end
end
context 'performance tests' do
let(:filler) do
%(<p>some word <a href="http://example.com?domain?example.com">some url</a> and the end.</p>\n) * 11 + "\n"
@ -574,6 +586,7 @@ RSpec.describe String do
</html>
HTML
end
end
end