diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index f7b762c05..b58f5735d 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -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:]]+$/, '') diff --git a/spec/lib/core_ext/string_spec.rb b/spec/lib/core_ext/string_spec.rb index d94fdc4d4..031a31e6b 100644 --- a/spec/lib/core_ext/string_spec.rb +++ b/spec/lib/core_ext/string_spec.rb @@ -542,6 +542,18 @@ RSpec.describe String do TEXT end + context 'html encoding' do + it 'converts Ä in Ä' do + expect('
some word some url and the end.
\n) * 11 + "\n" @@ -574,6 +586,7 @@ RSpec.describe String do