summaryrefslogtreecommitdiff
path: root/dev-ruby/mechanize/files/mechanize-2.9.1-libxml2-1.patch
blob: e2b72f2d8adff2796cb241deb7523acc8c473203 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 762df0c71705d1c054aca4abd95a638774a47242 Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@gmail.com>
Date: Wed, 7 Jun 2023 10:30:37 -0400
Subject: [PATCH] test: work around libxml2 encoding changes

versions 2.11.0..2.11.4 do not recover from encoding errors. upcoming
release will change the encoding of the resulting doc as a result of
recovery changes in libxml2.

See https://gitlab.gnome.org/GNOME/libxml2/-/issues/543 for more
context.
---
 test/test_mechanize_page_link.rb | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/test/test_mechanize_page_link.rb b/test/test_mechanize_page_link.rb
index 5e77dcc0..988328cc 100644
--- a/test/test_mechanize_page_link.rb
+++ b/test/test_mechanize_page_link.rb
@@ -1,5 +1,7 @@
 # coding: utf-8
 
+puts "Nokogiri::VERSION_INFO: #{Nokogiri::VERSION_INFO}"
+
 require 'mechanize/test_case'
 
 class TestMechanizePageLink < Mechanize::TestCase
@@ -111,11 +113,15 @@ def test_encoding_charset_after_title
   def test_encoding_charset_after_title_bad
     skip_if_nkf_dependency
 
+    # https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
+    skip if Nokogiri.uses_libxml?([">= 2.11.0", "<= 2.11.4"])
+    expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'
+
     page = util_page UTF8
 
     assert_equal false, page.encoding_error?
 
-    assert_equal 'UTF-8', page.encoding
+    assert_equal expected_encoding, page.encoding
   end
 
   def test_encoding_charset_after_title_double_bad
@@ -131,6 +137,10 @@ def test_encoding_charset_after_title_double_bad
   def test_encoding_charset_bad
     skip_if_nkf_dependency
 
+    # https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
+    skip if Nokogiri.uses_libxml?([">= 2.11.0", "<= 2.11.4"])
+    expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'
+
     page = util_page "<title>#{UTF8_TITLE}</title>"
     page.encodings.replace %w[
       UTF-8
@@ -139,7 +149,7 @@ def test_encoding_charset_bad
 
     assert_equal false, page.encoding_error?
 
-    assert_equal 'UTF-8', page.encoding
+    assert_equal expected_encoding, page.encoding
   end
 
   def test_encoding_meta_charset