summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-18 09:28:18 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-18 09:28:18 +0200
commit020078663e401798d199a1a293ac59d990f81dad (patch)
tree6a142474a0fdd838b9348d794e680737a44c22e7 /app/models/namespace.rb
parentcfdf94fc279e45ddbe0bbb94022a7488c663501c (diff)
downloadgitlab-ce-020078663e401798d199a1a293ac59d990f81dad.tar.gz
Prevent xss attack over group name. Added regex validation for group and team name
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 4e157839369..385fa291b48 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -17,11 +17,15 @@ class Namespace < ActiveRecord::Base
has_many :projects, dependent: :destroy
belongs_to :owner, class_name: "User"
- validates :name, presence: true, uniqueness: true
+ validates :owner, presence: true
+ validates :name, presence: true, uniqueness: true,
+ length: { within: 0..255 },
+ format: { with: Gitlab::Regex.name_regex,
+ message: "only letters, digits, spaces & '_' '-' '.' allowed." }
+
validates :path, uniqueness: true, presence: true, length: { within: 1..255 },
format: { with: Gitlab::Regex.path_regex,
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
- validates :owner, presence: true
delegate :name, to: :owner, allow_nil: true, prefix: true