From 233571a0585809d436fbe72646040676743231a7 Mon Sep 17 00:00:00 2001 From: John Shahid Date: Wed, 17 Feb 2016 18:57:10 -0500 Subject: [PATCH] Revert 3f2e575 and f7a3817 The fix for #444 turns out to cause issues with frozen strings (see #1077). Furthermore, MRI as of this commit behaves similar to JRuby, i.e. it adds the extra newline at the end of the fragment. --- ext/java/nokogiri/XmlDocumentFragment.java | 14 -------------- test/html/test_document_fragment.rb | 5 ----- 2 files changed, 19 deletions(-) diff --git a/ext/java/nokogiri/XmlDocumentFragment.java b/ext/java/nokogiri/XmlDocumentFragment.java index f2e636ab761..f1abce23f6d 100644 --- a/ext/java/nokogiri/XmlDocumentFragment.java +++ b/ext/java/nokogiri/XmlDocumentFragment.java @@ -54,7 +54,6 @@ import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; import org.w3c.dom.Attr; -import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; /** @@ -90,7 +89,6 @@ public static IRubyObject rbNew(ThreadContext context, IRubyObject cls, IRubyObj // make wellformed fragment, ignore invalid namespace, or add appropriate namespace to parse if (args.length > 1 && args[1] instanceof RubyString) { - args[1] = trim(context, doc, (RubyString)args[1]); if (XmlDocumentFragment.isTag((RubyString)args[1])) { args[1] = RubyString.newString(context.getRuntime(), addNamespaceDeclIfNeeded(doc, rubyStringToString(args[1]))); } @@ -107,18 +105,6 @@ public static IRubyObject rbNew(ThreadContext context, IRubyObject cls, IRubyObj RuntimeHelpers.invoke(context, fragment, "initialize", args); return fragment; } - - private static IRubyObject trim(ThreadContext context, XmlDocument xmlDocument, RubyString str) { - // checks whether schema is given. if exists, allows whitespace processing to a parser - Document document = (Document)xmlDocument.node; - if (document.getDoctype() != null) return str; - // strips trailing \n off forcefully - // not to return new object in case of no chomp needed, chomp! is used here. - IRubyObject result; - if (context.getRuntime().is1_9()) result = str.chomp19(context); - else result = str.chomp_bang(context); - return result.isNil() ? str : result; - } private static boolean isTag(RubyString ruby_string) { String str = rubyStringToString(ruby_string); diff --git a/test/html/test_document_fragment.rb b/test/html/test_document_fragment.rb index 8d5fee89cc8..54e4a0a9be9 100644 --- a/test/html/test_document_fragment.rb +++ b/test/html/test_document_fragment.rb @@ -296,11 +296,6 @@ def test_capturing_nonparse_errors_during_node_copy_between_fragments assert_equal original_errors1, frag1.errors assert_equal original_errors2, frag2.errors end - - def test_issue_444_trim_when_no_schem_given - fragment = Nokogiri::HTML::DocumentFragment.parse("

hi

\n").to_html - assert_equal "

hi

", fragment - end end end end