diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-07-19 14:03:40 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-07-19 14:03:40 +0300 |
commit | 928c81e2598da2a114011549b7aa68fce85fd077 (patch) | |
tree | d202ee0694fa70b4810fb3db092a441a990920f3 /lib | |
parent | ae3cdf93a11837cc1544debcec21e13d42666b5d (diff) | |
parent | 8ea9c81593bd43f38bcafc0ca18408889970cbd6 (diff) |
Merge branch 'use-rugged-for-reference-validator' into 'master'
Use rugged to validate ref name
Closes #49043
See merge request gitlab-org/gitlab-ce!20669
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git_ref_validator.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb index 2e3e4fc3f1f..40636fb204e 100644 --- a/lib/gitlab/git_ref_validator.rb +++ b/lib/gitlab/git_ref_validator.rb @@ -7,11 +7,11 @@ module Gitlab # # Returns true for a valid reference name, false otherwise def validate(ref_name) - return false if ref_name.start_with?('refs/heads/') - return false if ref_name.start_with?('refs/remotes/') + not_allowed_prefixes = %w(refs/heads/ refs/remotes/ -) + return false if ref_name.start_with?(*not_allowed_prefixes) + return false if ref_name == 'HEAD' - Gitlab::Utils.system_silent( - %W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name})) + Rugged::Reference.valid_name? "refs/heads/#{ref_name}" end end end |