From e9c0b88b7d5fadcfff84a4754d7df90c1469fb88 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Thu, 28 Jul 2011 14:47:54 -0300 Subject: [PATCH] Adding some more sites to trusted sites for iframe --- app/models/environment.rb | 14 +++++++++++++- db/migrate/069_add_enviroment_id_to_role.rb | 1 - db/migrate/083_set_visible_to_profiles.rb | 5 ----- db/migrate/20110706171330_fix_misunderstood_script_filename.rb | 6 ------ db/migrate/20110728173905_add_more_trusted_sites_for_environments.rb | 14 ++++++++++++++ db/schema.rb | 2 +- test/unit/environment_test.rb | 2 +- 7 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20110728173905_add_more_trusted_sites_for_environments.rb diff --git a/app/models/environment.rb b/app/models/environment.rb index d4faa05..7b2d8e8 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -226,7 +226,19 @@ class Environment < ActiveRecord::Base settings_items :currency_separator, :type => String, :default => '.' settings_items :currency_delimiter, :type => String, :default => ',' - settings_items :trusted_sites_for_iframe, :type => Array, :default => ['itheora.org', 'tv.softwarelivre.org', 'stream.softwarelivre.org', 'www.youtube.com', 'player.vimeo.com'] + settings_items :trusted_sites_for_iframe, :type => Array, :default => %w[ + developer.myspace.com + itheora.org + maps.google.com + platform.twitter.com + player.vimeo.com + stream.softwarelivre.org + tv.softwarelivre.org + www.facebook.com + www.flickr.com + www.gmodules.com + www.youtube.com + ] + ('a' .. 'z').map{|i| "#{i}.yimg.com"} settings_items :enabled_plugins, :type => Array, :default => [] diff --git a/db/migrate/069_add_enviroment_id_to_role.rb b/db/migrate/069_add_enviroment_id_to_role.rb index 219201d..a788f02 100644 --- a/db/migrate/069_add_enviroment_id_to_role.rb +++ b/db/migrate/069_add_enviroment_id_to_role.rb @@ -1,4 +1,3 @@ -class Environment < ActiveRecord::Base; end class Role < ActiveRecord::Base; end class RoleWithEnvironment < ActiveRecord::Base set_table_name 'roles' diff --git a/db/migrate/083_set_visible_to_profiles.rb b/db/migrate/083_set_visible_to_profiles.rb index 938cddf..181f95d 100644 --- a/db/migrate/083_set_visible_to_profiles.rb +++ b/db/migrate/083_set_visible_to_profiles.rb @@ -1,8 +1,3 @@ -class Environment < ActiveRecord::Base - set_table_name 'environments' - serialize :settings, Hash -end - class SetVisibleToProfiles < ActiveRecord::Migration def self.up templates = [] diff --git a/db/migrate/20110706171330_fix_misunderstood_script_filename.rb b/db/migrate/20110706171330_fix_misunderstood_script_filename.rb index aae4a3e..78460d3 100644 --- a/db/migrate/20110706171330_fix_misunderstood_script_filename.rb +++ b/db/migrate/20110706171330_fix_misunderstood_script_filename.rb @@ -21,12 +21,6 @@ class ArticleSweeper < ActiveRecord::Observer end end -class Environment < ActiveRecord::Base - def self.verify_filename(filename) - filename - end -end - class FixMisunderstoodScriptFilename < ActiveRecord::Migration def self.up Image.all.select { |i| !i.thumbnail? && File.extname(i.filename) == '.txt'}.map do |image| diff --git a/db/migrate/20110728173905_add_more_trusted_sites_for_environments.rb b/db/migrate/20110728173905_add_more_trusted_sites_for_environments.rb new file mode 100644 index 0000000..9eb17e1 --- /dev/null +++ b/db/migrate/20110728173905_add_more_trusted_sites_for_environments.rb @@ -0,0 +1,14 @@ +class AddMoreTrustedSitesForEnvironments < ActiveRecord::Migration + def self.up + default_sites = Environment.new.trusted_sites_for_iframe + Environment.all.each do |env| + env.trusted_sites_for_iframe += default_sites + env.trusted_sites_for_iframe.uniq! + env.save! + end + end + + def self.down + say 'Warning: This migration cant recover old data' + end +end diff --git a/db/schema.rb b/db/schema.rb index 84335f2..5e6268a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110714213405) do +ActiveRecord::Schema.define(:version => 20110728173905) do create_table "action_tracker", :force => true do |t| t.integer "user_id" diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index 29df127..fb74137 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -1071,7 +1071,7 @@ class EnvironmentTest < Test::Unit::TestCase end should 'have a list of trusted sites by default' do - assert_equal ['itheora.org', 'tv.softwarelivre.org', 'stream.softwarelivre.org', 'www.youtube.com', 'player.vimeo.com'], Environment.new.trusted_sites_for_iframe + assert_equal ['developer.myspace.com', 'itheora.org', 'maps.google.com', 'platform.twitter.com', 'player.vimeo.com', 'stream.softwarelivre.org', 'tv.softwarelivre.org', 'www.facebook.com', 'www.flickr.com', 'www.gmodules.com', 'www.youtube.com', 'a.yimg.com', 'b.yimg.com', 'c.yimg.com', 'd.yimg.com', 'e.yimg.com', 'f.yimg.com', 'g.yimg.com', 'h.yimg.com', 'i.yimg.com', 'j.yimg.com', 'k.yimg.com', 'l.yimg.com', 'm.yimg.com', 'n.yimg.com', 'o.yimg.com', 'p.yimg.com', 'q.yimg.com', 'r.yimg.com', 's.yimg.com', 't.yimg.com', 'u.yimg.com', 'v.yimg.com', 'w.yimg.com', 'x.yimg.com', 'y.yimg.com', 'z.yimg.com'], Environment.new.trusted_sites_for_iframe end should 'have a list of trusted sites' do -- libgit2 0.21.2