Skip to content

Commit

Permalink
Refactor methods in html node to avoid injects.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
miloops authored and spastorino committed Sep 24, 2010
1 parent abb99e3 commit 8105bc0
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,14 @@ def initialize(hash)
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

Expand Down

0 comments on commit 8105bc0

Please sign in to comment.