Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. Closes #8453.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7086 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
95c9ece59a
commit
40f6e9f8e1
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper]
|
||||||
|
|
||||||
* Backport clean_logger changes to support ruby 1.8.2 [mislav]
|
* Backport clean_logger changes to support ruby 1.8.2 [mislav]
|
||||||
|
|
||||||
* Added proper handling of arrays #8537 [hasmanyjosh]
|
* Added proper handling of arrays #8537 [hasmanyjosh]
|
||||||
|
|
|
@ -20,6 +20,27 @@ class Array
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Locked down XmlSimple#xml_in_string
|
||||||
|
class XmlSimple
|
||||||
|
# Same as xml_in but doesn't try to smartly shoot itself in the foot.
|
||||||
|
def xml_in_string(string, options = nil)
|
||||||
|
handle_options('in', options)
|
||||||
|
|
||||||
|
@doc = parse(string)
|
||||||
|
result = collapse(@doc.root)
|
||||||
|
|
||||||
|
if @options['keeproot']
|
||||||
|
merge({}, @doc.root.name, result)
|
||||||
|
else
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.xml_in_string(string, options = nil)
|
||||||
|
new.xml_in_string(string, options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module ActiveSupport #:nodoc:
|
module ActiveSupport #:nodoc:
|
||||||
module CoreExtensions #:nodoc:
|
module CoreExtensions #:nodoc:
|
||||||
module Hash #:nodoc:
|
module Hash #:nodoc:
|
||||||
|
@ -135,7 +156,7 @@ module ActiveSupport #:nodoc:
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def from_xml(xml)
|
def from_xml(xml)
|
||||||
# TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
|
# TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
|
||||||
typecast_xml_value(undasherize_keys(XmlSimple.xml_in(xml,
|
typecast_xml_value(undasherize_keys(XmlSimple.xml_in_string(xml,
|
||||||
'forcearray' => false,
|
'forcearray' => false,
|
||||||
'forcecontent' => true,
|
'forcecontent' => true,
|
||||||
'keeproot' => true,
|
'keeproot' => true,
|
||||||
|
|
Loading…
Reference in New Issue