summaryrefslogtreecommitdiff
path: root/lib/gitlab/path_regex.rb
diff options
context:
space:
mode:
authorHeinrich Lee Yu <hleeyu@gmail.com>2019-01-09 16:55:29 +0800
committerYorick Peterse <yorickpeterse@gmail.com>2019-01-31 16:51:16 +0100
commit219d24fe5298f6ca5a16d4392360fe1f691aee97 (patch)
tree54038050e7e813a006f1a1e546e41aadbaa9e2d5 /lib/gitlab/path_regex.rb
parent68d13322290a52360cd485d24bcfff995d98cf97 (diff)
downloadgitlab-ce-219d24fe5298f6ca5a16d4392360fe1f691aee97.tar.gz
Fix slow project reference pattern regex
Diffstat (limited to 'lib/gitlab/path_regex.rb')
-rw-r--r--lib/gitlab/path_regex.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb
index fa68dead80b..3c888be0710 100644
--- a/lib/gitlab/path_regex.rb
+++ b/lib/gitlab/path_regex.rb
@@ -125,7 +125,8 @@ module Gitlab
# allow non-regex validations, etc), `NAMESPACE_FORMAT_REGEX_JS` serves as a Javascript-compatible version of
# `NAMESPACE_FORMAT_REGEX`, with the negative lookbehind assertion removed. This means that the client-side validation
# will pass for usernames ending in `.atom` and `.git`, but will be caught by the server-side validation.
- PATH_REGEX_STR = '[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*'.freeze
+ PATH_START_CHAR = '[a-zA-Z0-9_\.]'.freeze
+ PATH_REGEX_STR = PATH_START_CHAR + '[a-zA-Z0-9_\-\.]*'.freeze
NAMESPACE_FORMAT_REGEX_JS = PATH_REGEX_STR + '[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'.freeze
NO_SUFFIX_REGEX = /(?<!\.git|\.atom)/.freeze