rubygem-nokogiri/nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch
Mamoru TASAKA ea58e84d09 1.15.5
Backport upstream patch for libxml2 2.12.0 error handling change
2023-11-18 22:50:51 +09:00

38 lines
1.3 KiB
Diff

From 5e60c08c6ec75ec8767f3edbfcba0d8e39d06495 Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@gmail.com>
Date: Tue, 24 Oct 2023 08:54:19 -0400
Subject: [PATCH] fix: work around change in upstream libxml2 recovery
See:
- https://gitlab.gnome.org/GNOME/libxml2/-/issues/598
- https://gitlab.gnome.org/GNOME/libxml2/-/commit/c082ef4644ce1f0af2a7c01e27c4a75f4d7d4feb
---
test/xml/sax/test_push_parser.rb | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/test/xml/sax/test_push_parser.rb b/test/xml/sax/test_push_parser.rb
index 5c9ddd3840..aa7ce84e8e 100644
--- a/test/xml/sax/test_push_parser.rb
+++ b/test/xml/sax/test_push_parser.rb
@@ -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(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