diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-08 18:15:23 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-08 18:15:23 +0300 |
commit | 6a0cb250966e3bca5bd0dcda82505bfd905167a7 (patch) | |
tree | 173c1143b4da63931d89df796c8c81a375265374 | |
parent | ac1ff491b4f68890381a6e397a342a78962ecad3 (diff) | |
download | gitlab-ce-6a0cb250966e3bca5bd0dcda82505bfd905167a7.tar.gz |
Dont allow ? in project path
Because it causes 500 error on every page where link to such project
exists
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | lib/gitlab/regex.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/regex_spec.rb | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 153613760fe..4b8038843b0 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -72,7 +72,7 @@ module Gitlab end def default_regex - /\A[.?]?[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*(?<!\.git)\z/ + /\A[a-zA-Z0-9_.][a-zA-Z0-9_\-\.]*(?<!\.git)\z/ end end end diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb new file mode 100644 index 00000000000..a3aae7771bd --- /dev/null +++ b/spec/lib/gitlab/regex_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Gitlab::Regex do + describe 'path regex' do + it { 'gitlab-ce'.should match(Gitlab::Regex.path_regex) } + it { 'gitlab_git'.should match(Gitlab::Regex.path_regex) } + it { '_underscore.js'.should match(Gitlab::Regex.path_regex) } + it { '100px.com'.should match(Gitlab::Regex.path_regex) } + it { '?gitlab'.should_not match(Gitlab::Regex.path_regex) } + it { 'git lab'.should_not match(Gitlab::Regex.path_regex) } + it { 'gitlab.git'.should_not match(Gitlab::Regex.path_regex) } + end + + describe 'project name regex' do + it { 'gitlab-ce'.should match(Gitlab::Regex.project_name_regex) } + it { 'GitLab CE'.should match(Gitlab::Regex.project_name_regex) } + it { '100 lines'.should match(Gitlab::Regex.project_name_regex) } + it { 'gitlab.git'.should match(Gitlab::Regex.project_name_regex) } + it { '?gitlab'.should_not match(Gitlab::Regex.project_name_regex) } + end +end |