Skip to content

Commit

Permalink
fix: work around change in upstream libxml2 recovery (#3013)
Browse files Browse the repository at this point in the history
**What problem is this PR intended to solve?**

Upstream libxml2 slightly changed encoding in recovery mode. Let's
update the one failing test, which is intended to test general recovery
mode error handling (and not encoding specifically) to be less specific
and forwards-compatible.

See:

- https://gitlab.gnome.org/GNOME/libxml2/-/issues/598
-
https://gitlab.gnome.org/GNOME/libxml2/-/commit/c082ef4644ce1f0af2a7c01e27c4a75f4d7d4feb
  • Loading branch information
flavorjones authored Oct 24, 2023
2 parents 49a0688 + 5e60c08 commit f74f48c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/xml/sax/test_push_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,18 @@ def error(msg)

it :test_broken_encoding do
skip_unless_libxml2("ultra hard to fix for pure Java version")

parser.options |= Nokogiri::XML::ParseOptions::RECOVER
# This is ISO_8859-1:
parser << "<?xml version='1.0' encoding='UTF-8'?><r>Gau\337</r>"
parser.finish

assert_operator(parser.document.errors.size, :>=, 1)
assert_equal "Gau\337", parser.document.data.join

# the interpretation of the byte may vary by libxml2 version in recovery mode
# see for example https://gitlab.gnome.org/GNOME/libxml2/-/issues/598
assert(parser.document.data.join.start_with?("Gau"))

assert_equal [["r"]], parser.document.end_elements
end

Expand Down

0 comments on commit f74f48c

Please sign in to comment.