Skip to content

Commit

Permalink
Use setStringInputStream instead of setInputStream.
Browse files Browse the repository at this point in the history
This is another place where we pass less information to the Java layer that was
missed in ba16682.
  • Loading branch information
jvshahid committed Sep 15, 2020
1 parent f895107 commit a41baac
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ext/java/nokogiri/XmlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,13 @@ public IRubyObject in_context(ThreadContext context, IRubyObject str, IRubyObjec
klass = getNokogiriClass(runtime, "Nokogiri::HTML::Document");
ctx = new HtmlDomParserContext(runtime, options);
((HtmlDomParserContext) ctx).enableDocumentFragment();
istream = new ByteArrayInputStream((rubyStringToString(str)).getBytes());
ctx.setStringInputSource(context, str, context.nil);
} else {
klass = getNokogiriClass(runtime, "Nokogiri::XML::Document");
ctx = new XmlDomParserContext(runtime, options);
String input = rubyStringToString(str);
istream = new ByteArrayInputStream(input.getBytes());
ctx.setStringInputSource(context, str, context.nil);
}

ctx.setInputSource(istream);
// TODO: for some reason, document.getEncoding() can be null or nil (don't know why)
// run `test_parse_with_unparented_html_text_context_node' few times to see this happen
if (document instanceof HtmlDocument && !(document.getEncoding() == null || document.getEncoding().isNil())) {
Expand Down

0 comments on commit a41baac

Please sign in to comment.