Commit 6cffcb05 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'allow-@' into 'master'

Allow "@" in file names and path

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/4111

See merge request !2665
parents 680d66db 72bd004b
...@@ -44,19 +44,19 @@ module Gitlab ...@@ -44,19 +44,19 @@ module Gitlab
def file_name_regex 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 end
def file_name_regex_message def file_name_regex_message
"can contain only letters, digits, '_', '-' and '.'. " "can contain only letters, digits, '_', '-', '@' and '.'. "
end end
def file_path_regex 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 end
def file_path_regex_message 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 end
......
...@@ -21,4 +21,12 @@ describe Gitlab::Regex, lib: true do ...@@ -21,4 +21,12 @@ describe Gitlab::Regex, lib: true do
it { expect('Dash – is this').to match(Gitlab::Regex.project_name_regex) } it { expect('Dash – is this').to match(Gitlab::Regex.project_name_regex) }
it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) } it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) }
end end
describe 'file name regex' do
it { expect('foo@bar').to match(Gitlab::Regex.file_name_regex) }
end
describe 'file path regex' do
it { expect('foo@/bar').to match(Gitlab::Regex.file_path_regex) }
end
end 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