Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7087

Show
Ignore:
Timestamp:
06/23/07 00:43:11 (3 years ago)
Author:
bitsweat
Message:

Merge [7086] to stable: demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. References #8453.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/activesupport/CHANGELOG

    r6794 r7087  
    11*SVN* 
     2 
     3* Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin.  #8453 [candlerb, Jeremy Kemper] 
    24 
    35* Document Object#blank?.  #6491 [Chris Mear] 
  • branches/1-2-stable/activesupport/lib/active_support/core_ext/hash/conversions.rb

    r5522 r7087  
    11require 'date' 
    22require 'xml_simple' 
     3 
     4# Locked down XmlSimple#xml_in_string 
     5class XmlSimple 
     6  # Same as xml_in but doesn't try to smartly shoot itself in the foot. 
     7  def xml_in_string(string, options = nil) 
     8    handle_options('in', options) 
     9 
     10    @doc = parse(string) 
     11    result = collapse(@doc.root) 
     12 
     13    if @options['keeproot'] 
     14      merge({}, @doc.root.name, result) 
     15    else 
     16      result 
     17    end 
     18  end 
     19 
     20  def self.xml_in_string(string, options = nil) 
     21    new.xml_in_string(string, options) 
     22  end 
     23end 
    324 
    425module ActiveSupport #:nodoc: 
     
    82103          def from_xml(xml) 
    83104            # TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple 
    84             undasherize_keys(typecast_xml_value(XmlSimple.xml_in(xml, 
     105            undasherize_keys(typecast_xml_value(XmlSimple.xml_in_string(xml, 
    85106              'forcearray'   => false, 
    86107              'forcecontent' => true, 
    87108              'keeproot'     => true, 
    88109              'contentkey'   => '__content__') 
    89             ))             
     110            )) 
    90111          end 
    91            
     112 
    92113          def create_from_xml(xml) 
    93114            ActiveSupport::Deprecation.warn("Hash.create_from_xml has been renamed to Hash.from_xml", caller)