From 10a63e2a0cbdc1e8e4d7aef87afc868bd599ca94 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Wed, 22 Sep 2010 11:36:09 -0300 Subject: Refactor methods in html node to avoid injects. Signed-off-by: Santiago Pastorino --- .../lib/action_controller/vendor/html-scanner/html/node.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_controller/vendor') diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb index 0eaad2b911..85250721e7 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb @@ -38,18 +38,14 @@ module HTML #:nodoc: private def keys_to_strings(hash) - hash.keys.inject({}) do |h,k| - h[k.to_s] = hash[k] - h - end + Hash[hash.keys.map {|k| [k.to_s, hash[k]]}] end def keys_to_symbols(hash) - hash.keys.inject({}) do |h,k| + Hash[hash.keys.map do |k| raise "illegal key #{k.inspect}" unless k.respond_to?(:to_sym) - h[k.to_sym] = hash[k] - h - end + [k.to_sym, hash[k]] + end] end end -- cgit v1.2.3