diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-19 14:31:47 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-19 14:31:47 +0200 |
commit | 2562a5c3aca30800c045a2ec4bce18477d4c5008 (patch) | |
tree | a387fa0a60239a3077031c0102a97c292c6e0a97 | |
parent | 9fe6c2b2c2dd92831c93297021b41d6721e4b201 (diff) | |
download | gitlab-ce-zj-environment-creation-regex-fix.tar.gz |
Allow % and ' as valid chars in environment nameszj-environment-creation-regex-fix
Lacking this was preventing users from initializing environment names
which mapped 1-on-1 with branch names when seeding using `gitlab-test`
as repository.
No docs needed update, at least from what I could grep.
Fixes gitlab-org/gitlab-ce#30855
-rw-r--r-- | lib/gitlab/regex.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/regex_spec.rb | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index e4d2a992470..4d622a60a40 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -39,11 +39,11 @@ module Gitlab end def environment_name_regex - @environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -]+\z/.freeze + @environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -%']+\z/.freeze end def environment_name_regex_message - "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces" + "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', '%', ''' and spaces" end def kubernetes_namespace_regex diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 0bee892fe0c..145606500fb 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -20,6 +20,21 @@ describe Gitlab::Regex, lib: true do it { is_expected.to match('foo@bar') } end + + describe '.environment_slug_regex' do + subject { described_class.environment_name_regex } + + it { is_expected.to match('foo') } + it { is_expected.to match('foo-1') } + it { is_expected.to match('FOO') } + it { is_expected.to match('foo/1') } + it { is_expected.to match('foo.1') } + it { is_expected.to match('foo%1') } + it { is_expected.to match("foo'1") } + it { is_expected.not_to match('9&foo') } + it { is_expected.not_to match('foo-^') } + end + describe '.environment_slug_regex' do subject { described_class.environment_slug_regex } |