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

refactor: simplify fix from 2e260f5 / #2434 #2447

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nokogiri/xml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def serialize(*args, &block)
options[:encoding] ||= document.encoding
encoding = Encoding.find(options[:encoding] || "UTF-8")

io = StringIO.new(String.new(encoding: encoding), "wb:#{encoding}:#{encoding}")
io = StringIO.new(String.new(encoding: encoding))

write_to(io, options, &block)
io.string
Expand Down
2 changes: 1 addition & 1 deletion test/xml/test_document_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestDocumentEncoding < Nokogiri::TestCase

# the document needs to be large enough to trigger a libxml2 buffer flush. the buffer size
# is determined by MINLEN in xmlIO.c, which is hardcoded to 4000 code points.
size = 4000
size = 8000
input = String.new(<<~XML, encoding: "UTF-16")
<?xml version="1.0" encoding="UTF-16"?>
<root>
Expand Down