From ea58e84d092cdbd3f989ce284ef44118420dd646 Mon Sep 17 00:00:00 2001 From: Mamoru TASAKA Date: Sat, 18 Nov 2023 22:50:51 +0900 Subject: [PATCH] 1.15.5 Backport upstream patch for libxml2 2.12.0 error handling change --- ...2973-libxml2-2_12_0-error-msg-change.patch | 42 +++++++++++++++++++ ...-libxml2-2_12_0-recovery-char-change.patch | 37 ++++++++++++++++ rubygem-nokogiri.spec | 12 +++++- sources | 4 +- 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 nokogiri-pr2973-libxml2-2_12_0-error-msg-change.patch create mode 100644 nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch diff --git a/nokogiri-pr2973-libxml2-2_12_0-error-msg-change.patch b/nokogiri-pr2973-libxml2-2_12_0-error-msg-change.patch new file mode 100644 index 0000000..94e1345 --- /dev/null +++ b/nokogiri-pr2973-libxml2-2_12_0-error-msg-change.patch @@ -0,0 +1,42 @@ +From 374f3281a67ab3a3e52ebe6deacc0548b3f1b96a Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +Date: Mon, 4 Sep 2023 12:58:45 -0400 +Subject: [PATCH] test: update to handle upstream libxml2 error changes + +The behavior changed in libxml2 commit 53050b1d +--- + test/xml/test_reader.rb | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/test/xml/test_reader.rb b/test/xml/test_reader.rb +index 4b5b5c5728..e5f01d32ec 100644 +--- a/test/xml/test_reader.rb ++++ b/test/xml/test_reader.rb +@@ -765,7 +765,12 @@ def test_broken_markup_attribute_hash + e = assert_raises(Nokogiri::XML::SyntaxError) do + reader.attribute_hash + end +- assert_includes(e.message, "FATAL: Extra content at the end of the document") ++ expected = if Nokogiri.uses_libxml?(">= 2.12.0") # upstream commit 53050b1d ++ "FATAL: Premature end of data in tag foo line 1" ++ else ++ "FATAL: Extra content at the end of the document" ++ end ++ assert_includes(e.message, expected) + end + + assert_equal(1, reader.errors.length) +@@ -796,7 +801,12 @@ def test_broken_markup_namespaces + e = assert_raises(Nokogiri::XML::SyntaxError) do + reader.namespaces + end +- assert_includes(e.message, "FATAL: Extra content at the end of the document") ++ expected = if Nokogiri.uses_libxml?(">= 2.12.0") # upstream commit 53050b1d ++ "FATAL: Premature end of data in tag foo line 1" ++ else ++ "FATAL: Extra content at the end of the document" ++ end ++ assert_includes(e.message, expected) + end + + assert_equal(1, reader.errors.length) diff --git a/nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch b/nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch new file mode 100644 index 0000000..f6e84d8 --- /dev/null +++ b/nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch @@ -0,0 +1,37 @@ +From 5e60c08c6ec75ec8767f3edbfcba0d8e39d06495 Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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 << "Gau\337" + 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 + diff --git a/rubygem-nokogiri.spec b/rubygem-nokogiri.spec index ab4c54c..bd16ba0 100644 --- a/rubygem-nokogiri.spec +++ b/rubygem-nokogiri.spec @@ -1,4 +1,4 @@ -%global mainver 1.15.4 +%global mainver 1.15.5 #%%global prever .rc4 %global baserelease 1 @@ -29,6 +29,10 @@ Source1: rubygem-%{gem_name}-%{version}%{?prever}-full.tar.gz Source2: nokogiri-create-full-tarball.sh # Shut down libxml2 version unmatching warning Patch0: %{name}-1.11.0.rc4-shutdown-libxml2-warning.patch +# https://github.com/sparklemotion/nokogiri/pull/2973 +Patch1: nokogiri-pr2973-libxml2-2_12_0-error-msg-change.patch +# https://github.com/sparklemotion/nokogiri/pull/3013 +Patch2: nokogiri-pr3013-libxml2-2_12_0-recovery-char-change.patch BuildRequires: ruby(release) BuildRequires: ruby(rubygems) ## @@ -81,6 +85,8 @@ mv ../%{gem_name}-%{version}.gemspec . # patches %patch -P0 -p1 +%patch -P1 -p1 +%patch -P2 -p1 # remove bundled external libraries sed -i \ @@ -266,6 +272,10 @@ popd %doc %{gem_dir}/doc/%{gem_name}-%{mainver}%{?prever}/ %changelog +* Sat Nov 18 2023 Mamoru TASAKA - 1.15.5-1 +- 1.15.5 +- Backport upstream patch for libxml2 2.12.0 error handling change + * Sat Aug 12 2023 Mamoru TASAKA - 1.15.4-1 - 1.15.4 diff --git a/sources b/sources index dbd6165..04feeac 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (nokogiri-1.15.4.gem) = 94587e0f87a44dcbaef3dfd29df0fb7cba9458a36fd4a486432b2718e93afc712fefce2a3618ccef6bb96a6578daca043ecd5c02de8bca3206b801cda1403c4c -SHA512 (rubygem-nokogiri-1.15.4-full.tar.gz) = 6655e2560a2d39f95859838fb6d8d0d5dcb74f5bf82cd06f183a39e94294df0eab4070ecc7f4a9002508e5f5171c6de7f692a5e0c3d83a79718b58b64f0462dd +SHA512 (nokogiri-1.15.5.gem) = 3f6c2febbdef2cc7e34b5555479b614165a4b3aaa8b46340812e2a736b3efd12c0d0e79c64ad2313a3d99326fd802eaab74eeda08c4ccd9a949974df69e0fe0f +SHA512 (rubygem-nokogiri-1.15.5-full.tar.gz) = 606b8fcc3483d4d834dc4cd9df73e56dbba6ad2c5c26223072f38f5e59b6746d913b73d9e3a6ffd4c5e52d5311c4efb0a78d3adae4545d6efdf826e4ab6a6985