Sha256: 37f8e5943d21f0d8fe21239655226f02e956e22468b1c1a3425952c52fde996f

Contents?: true

Size: 728 Bytes

Versions: 12

Compression:

Stored size: 728 Bytes

Contents

class CmsTemplate < ActiveRecord::Base
  acts_as_versioned
  
  attr_accessor :options
  
  has_many :pages, class_name: 'CmsPage'
  
  after_find :deserialize_yaml
  before_save :serialize_yaml
  
  def content=(value)
    if value && value.is_a?(String)
      # filter suspicious content... go overboard for now, fine-tune later perhaps
      value.gsub!(/<(%.*?(exec|system)\s?\(.*?\s*%)>/, '&lt;\1&gt;')
      value.gsub!(/<(%.*?\%x\s?\[.*?\s*%)>/, '&lt;\1&gt;')
      value.gsub!(/<(%.*?`.*?\s*%)>/, '&lt;\1&gt;')
    end
    super(value)
  end
  
  def deserialize_yaml
    @options = YAML.load(self.options_yaml) if self.options_yaml
  end
  
  def serialize_yaml
    self.options_yaml = YAML.dump(@options)
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
imagine_cms-5.2.6 app/models/cms_template.rb
imagine_cms-5.2.5 app/models/cms_template.rb
imagine_cms-5.2.4 app/models/cms_template.rb
imagine_cms-5.2.3 app/models/cms_template.rb
imagine_cms-5.2.2 app/models/cms_template.rb
imagine_cms-5.2.1 app/models/cms_template.rb
imagine_cms-5.2.0 app/models/cms_template.rb
imagine_cms-4.2.4 app/models/cms_template.rb
imagine_cms-4.2.3 app/models/cms_template.rb
imagine_cms-4.2.2 app/models/cms_template.rb
imagine_cms-4.2.1 app/models/cms_template.rb
imagine_cms-4.2.0 app/models/cms_template.rb