Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"null document" error when parsing an empty IO in jruby 1.7.3 #883

Closed
jcoyne opened this issue Apr 8, 2013 · 3 comments
Closed

"null document" error when parsing an empty IO in jruby 1.7.3 #883

jcoyne opened this issue Apr 8, 2013 · 3 comments

Comments

@jcoyne
Copy link

jcoyne commented Apr 8, 2013

Jruby 1.7.3

$ Nokogiri::XML.parse('')
=> #<Nokogiri::XML::Document:0x7fa name="document">
$ Nokogiri::XML.parse(StringIO.new(''))
Java::JavaLang::RuntimeException: null document
...

In Ruby 2.0.0:

$ Nokogiri::XML.parse('')
 => #<Nokogiri::XML::Document:0x3fd424b250b0 name="document"> 
$ Nokogiri::XML.parse(StringIO.new(''))
 => #<Nokogiri::XML::Document:0x3fd424b286c0 name="document"> 
@jcoyne
Copy link
Author

jcoyne commented Apr 8, 2013

I'm looking at https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/document.rb#L52-L53 and wondering if there ought to be a similar code like: return new if string_or_io.eof? in the block beginning on line 49.

@mbklein
Copy link
Contributor

mbklein commented Apr 12, 2013

Apparently it's not just read_memory that pukes on empty docs; it's Xerces, too. I can't imagine any harm from moving line 53 to before line 48 and skipping the whole block if the source IO is empty, but I don't have the cycles to try it out right now.

@flavorjones
Copy link
Member

@jcoyne You're probably right. Send a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants