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

Use private constant to test broken libxml version #1911

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 5 additions & 2 deletions lib/nokogiri/xml/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,20 @@ def add_sibling next_or_previous, node_or_tags
node_or_tags
end

IS_BROKEN_LIBXML_VERSION = defined?(LIBXML_VERSION) && LIBXML_VERSION.start_with?('2.6').freeze
private_constant :IS_BROKEN_LIBXML_VERSION

def to_format save_option, options
# FIXME: this is a hack around broken libxml versions
return dump_html if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
return dump_html if Nokogiri.uses_libxml? && IS_BROKEN_LIBXML_VERSION

options[:save_with] = save_option unless options[:save_with]
serialize(options)
end

def write_format_to save_option, io, options
# FIXME: this is a hack around broken libxml versions
return (io << dump_html) if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
return (io << dump_html) if Nokogiri.uses_libxml? && IS_BROKEN_LIBXML_VERSION

options[:save_with] ||= save_option
write_to io, options
Expand Down