Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-15 20:30:56 +0400
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-10-15 20:30:56 +0400
commitbd08cac88c8919f156c645f30beac81699ae0122 (patch)
treed0cf3e4b0ba84755cabf75fa0152b9e0cd7cf423 /app
parent82f79d71ea5417a4ca61892770a68a3ea9beb648 (diff)
project path & code regexp validation
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 17b556c3471..0d90af866bf 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base
validates :path,
:uniqueness => true,
:presence => true,
+ :format => { :with => /^[a-zA-Z0-9_\-]*$/,
+ :message => "only letters, digits & '_' '-' allowed" },
:length => { :within => 0..255 }
validates :description,
@@ -24,14 +26,15 @@ class Project < ActiveRecord::Base
validates :code,
:presence => true,
:uniqueness => true,
- :length => { :within => 3..12 }
+ :format => { :with => /^[a-zA-Z0-9_\-]*$/,
+ :message => "only letters, digits & '_' '-' allowed" },
+ :length => { :within => 3..16 }
validates :owner,
:presence => true
validate :check_limit
- before_save :format_code
after_destroy :destroy_gitosis_project
after_save :update_gitosis_project
@@ -47,10 +50,6 @@ class Project < ActiveRecord::Base
notes.where(:noteable_type => ["", nil])
end
- def format_code
- read_attribute(:code).downcase.strip.gsub(' ', '')
- end
-
def update_gitosis_project
Gitosis.new.configure do |c|
c.update_project(path, gitosis_writers)