GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/ddollar/rails.git
Merge [7086] to stable: demote Hash#to_xml to use XmlSimple#xml_in_string 
so it can't read files or stdin. References #8453.

git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7087 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jeremy (author)
Fri Jun 22 17:43:11 -0700 2007
commit  b29caa54e61cccfc330d47bbe5839970c94bb36e
tree    3e87f759fdce5bf93c884586ffae1377d5e21057
parent  7d517a145bebe3617f4a117e3685394396598182
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper]
0
+
0
 * Document Object#blank?. #6491 [Chris Mear]
0
 
0
 * Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
6
...
81
82
83
84
 
85
86
87
88
89
 
90
91
 
92
93
94
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
102
103
104
 
105
106
107
108
109
 
110
111
 
112
113
114
115
0
@@ -1,6 +1,27 @@
0
 require 'date'
0
 require 'xml_simple'
0
 
0
+# Locked down XmlSimple#xml_in_string
0
+class XmlSimple
0
+ # Same as xml_in but doesn't try to smartly shoot itself in the foot.
0
+ def xml_in_string(string, options = nil)
0
+ handle_options('in', options)
0
+
0
+ @doc = parse(string)
0
+ result = collapse(@doc.root)
0
+
0
+ if @options['keeproot']
0
+ merge({}, @doc.root.name, result)
0
+ else
0
+ result
0
+ end
0
+ end
0
+
0
+ def self.xml_in_string(string, options = nil)
0
+ new.xml_in_string(string, options)
0
+ end
0
+end
0
+
0
 module ActiveSupport #:nodoc:
0
   module CoreExtensions #:nodoc:
0
     module Hash #:nodoc:
0
@@ -81,14 +102,14 @@ module ActiveSupport #:nodoc:
0
         module ClassMethods
0
           def from_xml(xml)
0
             # TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
0
- undasherize_keys(typecast_xml_value(XmlSimple.xml_in(xml,
0
+ undasherize_keys(typecast_xml_value(XmlSimple.xml_in_string(xml,
0
               'forcearray' => false,
0
               'forcecontent' => true,
0
               'keeproot' => true,
0
               'contentkey' => '__content__')
0
- ))
0
+ ))
0
           end
0
-
0
+
0
           def create_from_xml(xml)
0
             ActiveSupport::Deprecation.warn("Hash.create_from_xml has been renamed to Hash.from_xml", caller)
0
             from_xml(xml)

Comments

    No one has commented yet.