aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini/nokogiri.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/xml_mini/nokogiri.rb')
-rw-r--r--activesupport/lib/active_support/xml_mini/nokogiri.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb
index 7337c143c9..622523a1b9 100644
--- a/activesupport/lib/active_support/xml_mini/nokogiri.rb
+++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb
@@ -9,13 +9,15 @@ module ActiveSupport
# data::
# XML Document string or IO to parse
def parse(data)
- if data.respond_to?(:read)
- data = data.read
+ if !data.respond_to?(:read)
+ data = StringIO.new(data || '')
end
-
- if data.blank?
+
+ char = data.getc
+ if char.nil?
{}
else
+ data.ungetc(char)
doc = Nokogiri::XML(data)
raise doc.errors.first if doc.errors.length > 0
doc.to_hash