Merge branch 'fix/encoding-issue' into 'master'
Fix encoding issue exporting a project Closes #31186 See merge request !10824
This commit is contained in:
commit
38e30516e1
3 changed files with 15 additions and 1 deletions
4
changelogs/unreleased/fix-encoding-issue.yml
Normal file
4
changelogs/unreleased/fix-encoding-issue.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix encoding issue exporting a project
|
||||
merge_request:
|
||||
author:
|
|
@ -40,7 +40,13 @@ module Gitlab
|
|||
def encode_utf8(message)
|
||||
detect = CharlockHolmes::EncodingDetector.detect(message)
|
||||
if detect
|
||||
CharlockHolmes::Converter.convert(message, detect[:encoding], 'UTF-8')
|
||||
begin
|
||||
CharlockHolmes::Converter.convert(message, detect[:encoding], 'UTF-8')
|
||||
rescue ArgumentError => e
|
||||
Rails.logger.warn("Ignoring error converting #{detect[:encoding]} into UTF8: #{e.message}")
|
||||
|
||||
''
|
||||
end
|
||||
else
|
||||
clean(message)
|
||||
end
|
||||
|
|
|
@ -56,6 +56,10 @@ describe Gitlab::Git::EncodingHelper do
|
|||
expect(r.encoding.name).to eq('UTF-8')
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns empty string on conversion errors' do
|
||||
expect { ext_class.encode_utf8('') }.not_to raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#clean' do
|
||||
|
|
Loading…
Reference in a new issue