Skip to content
Snippets Groups Projects
Commit e9cf661b authored by Stan Hu's avatar Stan Hu
Browse files

Merge branch 'attributes-ignore-invalid-encoding' into 'master'

Ignore invalid encoding when parsing attributes

See https://gitlab.com/gitlab-org/gitlab_git/issues/28 for the discussion leading up to these changes.

See merge request !129
parents 3214a656 45580062
No related branches found
No related tags found
1 merge request!129Ignore invalid encoding when parsing attributes
Pipeline #
v 10.6.10
- Ignore invalid encodings when parsing Git attribute files
v 10.6.9
- Optimize diff creation from Rugged::Patch
 
Loading
Loading
Loading
Loading
@@ -99,6 +99,8 @@ module Gitlab
 
File.open(full_path, 'r') do |handle|
handle.each_line do |line|
break unless line.valid_encoding?
yield line.strip
end
end
Loading
Loading
Loading
Loading
@@ -139,5 +139,12 @@ describe Gitlab::Git::Attributes do
 
expect { |b| subject.each_line(&b) }.not_to yield_control
end
it 'does not yield when the attributes file has an unsupported encoding' do
path = File.expand_path(File.join(SUPPORT_PATH, 'with-invalid-git-attributes.git'))
attrs = described_class.new(path)
expect { |b| attrs.each_line(&b) }.not_to yield_control
end
end
end
Loading
Loading
@@ -13,6 +13,7 @@ module SeedHelper
create_mutable_seeds
create_broken_seeds
create_git_attributes
create_invalid_git_attributes
end
 
def create_bare_seeds
Loading
Loading
@@ -75,6 +76,18 @@ bla/bla.txt
end
end
 
def create_invalid_git_attributes
dir = File.join(SUPPORT_PATH, 'with-invalid-git-attributes.git', 'info')
FileUtils.mkdir_p(dir)
enc = Encoding::UTF_16
File.open(File.join(dir, 'attributes'), 'w', encoding: enc) do |handle|
handle.write('# hello'.encode(enc))
end
end
# Prevent developer git configurations from being persisted to test
# repositories
def git_env
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment