From 62b1b1722165547bb7d0d8e0a3221f43b9de63d9 Mon Sep 17 00:00:00 2001 From: Josh Nussbaum Date: Thu, 20 Apr 2017 16:31:50 -0400 Subject: Fixes Hash.from_xml with frozen strings for all backends --- activesupport/lib/active_support/xml_mini/libxml.rb | 4 +--- activesupport/lib/active_support/xml_mini/libxmlsax.rb | 5 +---- activesupport/lib/active_support/xml_mini/nokogiri.rb | 4 +--- activesupport/lib/active_support/xml_mini/nokogirisax.rb | 4 +--- 4 files changed, 4 insertions(+), 13 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/xml_mini/libxml.rb b/activesupport/lib/active_support/xml_mini/libxml.rb index cde2967132..d849cdfa6b 100644 --- a/activesupport/lib/active_support/xml_mini/libxml.rb +++ b/activesupport/lib/active_support/xml_mini/libxml.rb @@ -14,11 +14,9 @@ module ActiveSupport data = StringIO.new(data || "") end - char = data.getc - if char.nil? + if data.eof? {} else - data.ungetc(char) LibXML::XML::Parser.io(data).parse.to_hash end end diff --git a/activesupport/lib/active_support/xml_mini/libxmlsax.rb b/activesupport/lib/active_support/xml_mini/libxmlsax.rb index 8a43b05b17..f3d485da2f 100644 --- a/activesupport/lib/active_support/xml_mini/libxmlsax.rb +++ b/activesupport/lib/active_support/xml_mini/libxmlsax.rb @@ -65,12 +65,9 @@ module ActiveSupport data = StringIO.new(data || "") end - char = data.getc - if char.nil? + if data.eof? {} else - data.ungetc(char) - LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER) parser = LibXML::XML::SaxParser.io(data) document = document_class.new diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb index 4c2be3f3ec..63466c08b2 100644 --- a/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb @@ -19,11 +19,9 @@ module ActiveSupport data = StringIO.new(data || "") end - char = data.getc - if char.nil? + if data.eof? {} else - data.ungetc(char) doc = Nokogiri::XML(data) raise doc.errors.first if doc.errors.length > 0 doc.to_hash diff --git a/activesupport/lib/active_support/xml_mini/nokogirisax.rb b/activesupport/lib/active_support/xml_mini/nokogirisax.rb index 7388bea5d8..54e15e6a5f 100644 --- a/activesupport/lib/active_support/xml_mini/nokogirisax.rb +++ b/activesupport/lib/active_support/xml_mini/nokogirisax.rb @@ -71,11 +71,9 @@ module ActiveSupport data = StringIO.new(data || "") end - char = data.getc - if char.nil? + if data.eof? {} else - data.ungetc(char) document = document_class.new parser = Nokogiri::XML::SAX::Parser.new(document) parser.parse(data) -- cgit v1.2.3