Commit 124a0cab authored by Douwe Maan's avatar Douwe Maan

Merge branch 'sh-handle-string-null-bytes' into 'master'

Gracefully handle references with null bytes

Closes #54466

See merge request gitlab-org/gitlab-ce!23365
parents ea8f0f3b e36c347f
---
title: Gracefully handle references with null bytes
merge_request: 23365
author:
type: fixed
......@@ -13,7 +13,11 @@ module Gitlab
return false if ref_name.start_with?(*not_allowed_prefixes)
return false if ref_name == 'HEAD'
Rugged::Reference.valid_name? "refs/heads/#{ref_name}"
begin
Rugged::Reference.valid_name?("refs/heads/#{ref_name}")
rescue ArgumentError
return false
end
end
end
end
......@@ -27,4 +27,5 @@ describe Gitlab::GitRefValidator do
it { expect(described_class.validate('-branch')).to be_falsey }
it { expect(described_class.validate('.tag')).to be_falsey }
it { expect(described_class.validate('my branch')).to be_falsey }
it { expect(described_class.validate("\xA0\u0000\xB0")).to be_falsey }
end
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