diff options
author | Brian Lopez <seniorlopez@gmail.com> | 2009-06-09 09:01:50 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-06-09 09:01:50 -0500 |
commit | 69bc2043f93890048e415dd7c5f1feba5a20d145 (patch) | |
tree | 619404d1d54a50e44a7b2642ece47e2f2a6c17b5 /activesupport/lib/active_support/xml_mini/libxml.rb | |
parent | a94e7d7897a300a95d5d5a00c5efc573b42bcb58 (diff) | |
download | rails-69bc2043f93890048e415dd7c5f1feba5a20d145.tar.gz rails-69bc2043f93890048e415dd7c5f1feba5a20d145.tar.bz2 rails-69bc2043f93890048e415dd7c5f1feba5a20d145.zip |
enable *real* IO parsing for the libxml, nokogiri and rexml backends [#2659 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport/lib/active_support/xml_mini/libxml.rb')
-rw-r--r-- | activesupport/lib/active_support/xml_mini/libxml.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/xml_mini/libxml.rb b/activesupport/lib/active_support/xml_mini/libxml.rb index d4c4dc7be5..2ae22c35fb 100644 --- a/activesupport/lib/active_support/xml_mini/libxml.rb +++ b/activesupport/lib/active_support/xml_mini/libxml.rb @@ -9,16 +9,18 @@ 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 - + LibXML::XML.default_keep_blanks = false - - if data.blank? + + char = data.getc + if char.nil? {} else - LibXML::XML::Parser.string(data.strip).parse.to_hash + data.ungetc(char) + LibXML::XML::Parser.io(data).parse.to_hash end end |