diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/container_registry/path.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/regex.rb | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb index 27e0e7897ff..6e8d62b77c7 100644 --- a/lib/container_registry/path.rb +++ b/lib/container_registry/path.rb @@ -22,7 +22,9 @@ module ContainerRegistry end def valid? - @nodes.size > 1 && @nodes.size < Namespace::NUMBER_OF_ANCESTORS_ALLOWED + @path =~ Gitlab::Regex.container_repository_name_regex && + @nodes.size > 1 && + @nodes.size < Namespace::NUMBER_OF_ANCESTORS_ALLOWED end def components diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 5e5f5ff1589..e599dd4a656 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -121,6 +121,13 @@ module Gitlab git_reference_regex end + ## + # Docker Distribution Registry 2.4.1 repository name rules + # + def container_repository_name_regex + @container_repository_regex ||= %r{\A[a-z0-9]+(?:[-._/][a-z0-9]+)*\Z} + end + def environment_name_regex @environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -]+\z/.freeze end |