Commit f638643f authored by Stan Hu's avatar Stan Hu

Ignore .gitattributes if they contain invalid byte sequences

Users that accidentally insert null bytes or other bytes may see 500
errors loading merge requests. To avoid that, we catch the bad data in
.gitattributes and ignore it.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/216210
parent 4e75712d
---
title: Ignore .gitattributes if they contain invalid byte sequences
merge_request: 30922
author:
type: fixed
......@@ -85,6 +85,8 @@ module Gitlab
yield line.strip
end
# Catch invalid byte sequences
rescue ArgumentError
end
private
......
......@@ -75,6 +75,14 @@ describe Gitlab::Git::AttributesParser, :seed_helper do
expect(subject.attributes('test.foo')).to eq({})
end
end
context 'when attributes data has binary data' do
let(:data) { "\xFF\xFE*\u0000.\u0000c\u0000s".b }
it 'returns an empty Hash' do
expect(subject.attributes('test.foo')).to eq({})
end
end
end
describe '#patterns' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment