summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-09-04 17:10:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-09-04 17:10:12 +0000
commit45a0daa16a140d2d41a114e2fc2270a6fa688c93 (patch)
treeb15a58999867a9d721b76f0717b643fcb8bd7fd2 /app/models/repository.rb
parentdcf2e15b0617e4e0aa2cc4b7dde2c59b688c535a (diff)
downloadredmine-45a0daa16a140d2d41a114e2fc2270a6fa688c93.tar.gz
redmine-45a0daa16a140d2d41a114e2fc2270a6fa688c93.zip
Be more conservative when fetching constants in Repository.factory (#23758).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@15816 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 5f2f118b7..6da088541 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -363,10 +363,14 @@ class Repository < ActiveRecord::Base
end
def self.factory(klass_name, *args)
- klass = "Repository::#{klass_name}".constantize
- klass.new(*args)
- rescue
- nil
+ repository_class(klass_name).new(*args) rescue nil
+ end
+
+ def self.repository_class(class_name)
+ class_name = class_name.to_s.classify
+ if Redmine::Scm::Base.all.include?(class_name)
+ "Repository::#{class_name}".constantize
+ end
end
def self.scm_adapter_class