From 5ddc597066603875b4e59c811d0d78c84842111c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 10 Jan 2010 18:13:43 -0800 Subject: Use safe_concat instead of trying to html_safe! what might be a frozen string --- actionpack/lib/action_controller/caching/fragments.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb index 806e6a1750..00a7f034d3 100644 --- a/actionpack/lib/action_controller/caching/fragments.rb +++ b/actionpack/lib/action_controller/caching/fragments.rb @@ -36,8 +36,8 @@ module ActionController #:nodoc: def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc: if perform_caching - if fragment_exist?(name,options) - buffer.concat(read_fragment(name, options).html_safe!) + if fragment_exist?(name, options) + buffer.safe_concat(read_fragment(name, options)) else pos = buffer.length block.call -- cgit v1.2.3 From 2c2b84f93c6eb1a170467c1340a4eeddfa13f7da Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 10 Jan 2010 18:25:17 -0800 Subject: Javascript tests expects the old default of escaping HTML, make it so for now --- actionpack/test/template/javascript_helper_test.rb | 5 +++++ actionpack/test/template/prototype_helper_test.rb | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'actionpack') diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb index f0f686f6e2..03caad3d46 100644 --- a/actionpack/test/template/javascript_helper_test.rb +++ b/actionpack/test/template/javascript_helper_test.rb @@ -13,8 +13,13 @@ class JavaScriptHelperTest < ActionView::TestCase def setup super + ActiveSupport.escape_html_entities_in_json = true @template = self end + + def teardown + ActiveSupport.escape_html_entities_in_json = false + end def _evaluate_assigns_and_ivars() end diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index 313a769088..9225153798 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -317,6 +317,11 @@ class JavaScriptGeneratorTest < PrototypeHelperBaseTest def setup super @generator = create_generator + ActiveSupport.escape_html_entities_in_json = true + end + + def teardown + ActiveSupport.escape_html_entities_in_json = false end def _evaluate_assigns_and_ivars() end -- cgit v1.2.3 From 02bbde4e78f958d5495c19d953aaec58bb8ef998 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 10 Jan 2010 23:09:10 -0600 Subject: Cleanup junk metal and revise API API Change: Returning a "X-Cascade: pass" header triggers the cascade instead of a 404 response. --- actionpack/lib/action_controller/railtie.rb | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 6b94c32b2a..42257f9400 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -37,11 +37,33 @@ module ActionController ActionController::Base.view_paths = view_path if ActionController::Base.view_paths.blank? end + class MetalMiddlewareBuilder + def initialize(metals) + @metals = metals + end + + def new(app) + ActionDispatch::Cascade.new(@metals, app) + end + + def name + ActionDispatch::Cascade.name + end + alias_method :to_s, :name + end + initializer "action_controller.initialize_metal" do |app| - Rails::Rack::Metal.requested_metals = app.config.metals + metal_root = "#{Rails.root}/app/metal" + load_list = app.config.metals || Dir["#{metal_root}/**/*.rb"] + + metals = load_list.map { |metal| + metal = File.basename(metal.gsub("#{metal_root}/", ''), '.rb') + require_dependency metal + metal.camelize.constantize + }.compact - app.config.middleware.insert_before(:"ActionDispatch::ParamsParser", - Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) + middleware = MetalMiddlewareBuilder.new(metals) + app.config.middleware.insert_before(:"ActionDispatch::ParamsParser", middleware) end # # Prepare dispatcher callbacks and run 'prepare' callbacks -- cgit v1.2.3