From 143717b388cc5af5b2f0f320f0e18ec9f261591a Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Wed, 27 Jul 2016 13:49:03 -0500 Subject: [PATCH] Allow colons in file path and name --- CHANGELOG | 1 + lib/gitlab/regex.rb | 8 ++++---- spec/lib/gitlab/regex_spec.rb | 14 ++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a4dbce95268a..2b7e06829d5a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ v 8.11.0 (unreleased) - Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable - Optimize maximum user access level lookup in loading of notes - Limit git rev-list output count to one in forced push check + - Allow colons in file path and name !5529 - Clean up unused routes (Josef Strzibny) - Add green outline to New Branch button. !5447 (winniehell) - Retrieve rendered HTML from cache in one request diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index ffad5e17c783..7ff34b73a269 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -40,19 +40,19 @@ def project_path_regex_message end def file_name_regex - @file_name_regex ||= /\A[a-zA-Z0-9_\-\.\@]*\z/.freeze + @file_name_regex ||= /\A[a-zA-Z0-9_\-\.\@\:]*\z/.freeze end def file_name_regex_message - "can contain only letters, digits, '_', '-', '@' and '.'. " + "can contain only letters, digits, '_', '-', '@', ':', and '.'. " end def file_path_regex - @file_path_regex ||= /\A[a-zA-Z0-9_\-\.\/\@]*\z/.freeze + @file_path_regex ||= /\A[a-zA-Z0-9_\-\.\/\@\:]*\z/.freeze end def file_path_regex_message - "can contain only letters, digits, '_', '-', '@' and '.'. Separate directories with a '/'. " + "can contain only letters, digits, '_', '-', '@', ':', and '.'. Separate directories with a '/'. " end def directory_traversal_regex diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index c51b10bdc69b..68d698cf8d1a 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -22,11 +22,17 @@ it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) } end - describe 'file name regex' do - it { expect('foo@bar').to match(Gitlab::Regex.file_name_regex) } + describe '#file_name_regex' do + subject { described_class.file_name_regex } + + it { is_expected.to match('foo@bar') } + it { is_expected.to match('foo:bar') } end - describe 'file path regex' do - it { expect('foo@/bar').to match(Gitlab::Regex.file_path_regex) } + describe '#file_path_regex' do + subject { described_class.file_path_regex } + + it { is_expected.to match('foo@/bar') } + it { is_expected.to match('foo:bar/baz') } end end -- GitLab