def create
attrs = pickup_extra_info
- @repository = Repository.factory(params[:repository_scm], attrs[:attrs])
+ @repository = Repository.factory(params[:repository_scm])
+ @repository.safe_attributes = params[:repository]
if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
def update
attrs = pickup_extra_info
- @repository.attributes = attrs[:attrs]
+ @repository.safe_attributes = attrs[:attrs]
if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
class Repository < ActiveRecord::Base
include Redmine::Ciphering
+ include Redmine::SafeAttributes
belongs_to :project
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
# Checks if the SCM is enabled when creating a repository
validate :repo_create_validation, :on => :create
+ safe_attributes 'identifier',
+ 'url',
+ 'login',
+ 'password',
+ 'path_encoding',
+ 'log_encoding',
+ 'is_default'
+
def repo_create_validation
unless Setting.enabled_scm.include?(self.class.name.demodulize)
errors.add(:type, :invalid)
class Repository::Cvs < Repository
validates_presence_of :url, :root_url, :log_encoding
+ safe_attributes 'root_url'
+
def self.human_attribute_name(attribute_key_name, *args)
attr_name = attribute_key_name.to_s
if attr_name == "root_url"
def safe_attributes(*args)
@safe_attributes ||= []
if args.empty?
- @safe_attributes
+ if superclass.include?(Redmine::SafeAttributes)
+ @safe_attributes + superclass.safe_attributes
+ else
+ @safe_attributes
+ end
else
options = args.last.is_a?(Hash) ? args.pop : {}
@safe_attributes << [args, options]