Merge branch 'fix/encoding-issue' into 'master'

Fix encoding issue exporting a project

Closes #31186

See merge request !10824
This commit is contained in:
Sean McGivern 2017-04-21 09:40:48 +00:00
commit 38e30516e1
3 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,4 @@
---
title: Fix encoding issue exporting a project
merge_request:
author:

View file

@ -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

View file

@ -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