mechanize 2.9.1 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3090de20e06b18db1768b33b3f446a039d69b653002a03fc2576f8f821e996b5
4
- data.tar.gz: 69f38522fee7861b2c39130a67e168b6b78c0d3d301e6f6d640d5cb175586486
3
+ metadata.gz: 657e0dcff19a6db26a52cf94584a987b9cd231bee579fc10662b0ef677716a68
4
+ data.tar.gz: 2f706289ddcdf0090303f0bdcf9771ea3d4547b4d31f1c0ab31ac930bc25485c
5
5
  SHA512:
6
- metadata.gz: a11a74bb5118f20cd4a31673f40595882192b8c84d33d6bf6d116e007afe6e369ce7ae7f1dc832f34a94d6dc7a2732c82462351f62b53bdaab0ed6bcf2ea8bd6
7
- data.tar.gz: 2bc5af7fb18fcdffa84f255777317f1729b454dc3f8539de27ad172991c49c250de457464691d63c85c32006ecb4105137b653f1c78ea948425e54aa562b2b98
6
+ metadata.gz: 901b1386243cd9755b9fd47d4365f3ceace2c62b8f1d344b4eb01bfa0930bcc0812a18b5f87aba95494b7341e402441915d0682dc06fd04360ea3320950a9e86
7
+ data.tar.gz: 1491b3ca0b17590cfd1bfc01af9a9782d77728ccf54deab4f7f583d3d3bf7831df824cef18af6f98734bcdffddfc5e2dd03d1fe86acf877efe500d051c90f731
@@ -5,6 +5,9 @@ concurrency:
5
5
  cancel-in-progress: true
6
6
 
7
7
  on:
8
+ workflow_dispatch:
9
+ schedule:
10
+ - cron: "0 8 * * 5" # At 08:00 on Friday # https://crontab.guru/#0_8_*_*_5
8
11
  push:
9
12
  branches:
10
13
  - main
@@ -12,8 +15,6 @@ on:
12
15
  types: [opened, synchronize]
13
16
  branches:
14
17
  - main
15
- schedule:
16
- - cron: "0 8 * * 5" # At 08:00 on Friday # https://crontab.guru/#0_8_*_*_5
17
18
 
18
19
  jobs:
19
20
  rubocop:
@@ -31,7 +32,7 @@ jobs:
31
32
  strategy:
32
33
  fail-fast: false
33
34
  matrix:
34
- ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "head", "jruby-9.4", "truffleruby-head"]
35
+ ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "head", "jruby-9.4", "truffleruby-head"]
35
36
 
36
37
  runs-on: ubuntu-latest
37
38
  steps:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Mechanize CHANGELOG
2
2
 
3
+ ## 2.9.2 / 2024-01-15
4
+
5
+ * Correct spelling errors in documentation. (#631) @p-linnane
6
+ * Updated User-Agent strings to represent modern browser versions. (#632) @takatea
7
+
8
+
3
9
  ## 2.9.1 / 2023-04-17
4
10
 
5
11
  ### Update
@@ -109,7 +115,7 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
109
115
  * Fix element(s)_with(search: selector) methods not working for forms, form fields and frames. (#444)
110
116
  * Improve the filename parser for the `Content-Disposition` header. (#496, #517)
111
117
  * Accept `Content-Encoding: identity`. (#515)
112
- * Mechanize::Page#title no longer picks a title in an embeded SVG/RDF element. (#503)
118
+ * Mechanize::Page#title no longer picks a title in an embedded SVG/RDF element. (#503)
113
119
  * Make Mechanize::Form#has_field? boolean. (#501)
114
120
 
115
121
  ## 2.7.5
@@ -415,8 +421,8 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
415
421
  * When given multiple HTTP authentication options mechanize now picks the
416
422
  strongest method.
417
423
  * Improvements to HTTP authorization:
418
- * mechanize raises Mechanize::UnathorizedError for 401 responses which is
419
- a sublcass of Mechanize::ResponseCodeError.
424
+ * mechanize raises Mechanize::UnauthorizedError for 401 responses which is
425
+ a subclass of Mechanize::ResponseCodeError.
420
426
  * Added support for NTLM authentication, but this has not been tested.
421
427
  * Mechanize::Cookie.new accepts attributes in a hash.
422
428
  * Mechanize::CookieJar#<<(cookie) (alias: add!) is added. Issue #139
@@ -507,7 +513,7 @@ Mechanize is now under the MIT license
507
513
 
508
514
  * New Features
509
515
 
510
- * Add header reference methods to Mechanize::File so that a reponse
516
+ * Add header reference methods to Mechanize::File so that a response
511
517
  object gets compatible with Net::HTTPResponse.
512
518
  * Mechanize#click accepts a regexp or string to click a button/link in the
513
519
  current page. It works as expected when not passed a string or regexp.
@@ -732,7 +738,7 @@ Mechanize is now under the MIT license
732
738
  http://d.hatena.ne.jp/kitamomonga/20080410/ruby_mechanize_percent_url_bug
733
739
  * #21132 Not checking for EOF errors on redirect
734
740
  * Fixed a weird gzipping error.
735
- * #21233 Smarter multipart boundry. Thanks Todd Willey!
741
+ * #21233 Smarter multipart boundary. Thanks Todd Willey!
736
742
  * #20097 Supporting meta tag cookies.
737
743
 
738
744
  ## 0.7.6
@@ -841,7 +847,7 @@ Mechanize is now under the MIT license
841
847
  * [#9877] Moved last request time. Thanks Max Stepanov
842
848
  * Added WWW::Mechanize::File#save
843
849
  * Defaulting file name to URI or Content-Disposition
844
- * Updating compatability with hpricot
850
+ * Updating compatibility with hpricot
845
851
  * Added more unit tests
846
852
 
847
853
  ## 0.6.7
@@ -853,7 +859,7 @@ Mechanize is now under the MIT license
853
859
 
854
860
  * Removing hpricot overrides
855
861
  * Fixed a bug where alt text can be nil. Thanks Yannick!
856
- * Unparseable expiration dates in cookies are now treated as session cookies
862
+ * Unparsable expiration dates in cookies are now treated as session cookies
857
863
  * Caching connections
858
864
  * Requests now default to keep alive
859
865
  * [#9434] Fixed bug where html entities weren't decoded
@@ -919,7 +925,7 @@ Mechanize is now under the MIT license
919
925
  * Added a method to Form called "submit". Now forms can be submitted by
920
926
  calling a method on the form.
921
927
  * Added a click method to links
922
- * Added an REXML pluggable parser for backwards compatability. To use it,
928
+ * Added an REXML pluggable parser for backwards compatibility. To use it,
923
929
  just do this:
924
930
  agent.pluggable_parser.html = WWW::Mechanize::REXMLPage
925
931
  * Fixed a bug with referrers by adding a page attribute to forms and links.
@@ -1046,7 +1052,7 @@ Mechanize is now under the MIT license
1046
1052
 
1047
1053
  ## 0.4.4
1048
1054
 
1049
- * Fixed error in method signature, basic_authetication is now basic_auth
1055
+ * Fixed error in method signature, basic_authentication is now basic_auth
1050
1056
  * Fixed bug with encoding names in file uploads (Big thanks to Alex Young)
1051
1057
  * Added options to the select list
1052
1058
 
@@ -1,8 +1,23 @@
1
1
  require 'mechanize'
2
+ require 'ostruct'
2
3
 
4
+ # LatestUAFetcher fetches latest user agents from `WhatIsMyBrowser.com`.
5
+ # It can use to update `Mechanize::AGENT_ALIASES`.
3
6
  class LatestUAFetcher
4
7
  attr_reader :user_agents
5
8
 
9
+ USER_AGENT_TYPES = OpenStruct.new(
10
+ linux_firefox: "Linux Firefox",
11
+ mac_firefox: "Mac Firefox",
12
+ mac_safari: "Mac Safari",
13
+ windows_chrome: "Windows Chrome",
14
+ windows_edge: "Windows Edge",
15
+ windows_firefox: "Windows Firefox",
16
+ android: "Android",
17
+ iphone: "iPhone",
18
+ ipad: "iPad",
19
+ )
20
+
6
21
  BASE_URL = 'https://www.whatismybrowser.com/guides/the-latest-user-agent'
7
22
 
8
23
  def initialize
@@ -11,36 +26,37 @@ class LatestUAFetcher
11
26
  end
12
27
 
13
28
  def run
14
- sleep_time = 1
15
-
16
- puts 'get chrome UA...'
17
- chrome
18
- puts "sleeping... (#{sleep_time}s)"
19
- sleep 1
29
+ return unless user_agents.empty?
20
30
 
21
- puts 'get firefox UA...'
22
- firefox
23
- puts "sleeping... (#{sleep_time}s)"
24
- sleep 1
31
+ sleep_time = 1
25
32
 
26
- puts 'get safari UA...'
27
- safari
28
- puts "sleeping... (#{sleep_time}s)"
29
- sleep 1
33
+ fetch_user_agents('chrome')
34
+ fetch_user_agents('firefox')
35
+ fetch_user_agents('safari')
36
+ fetch_user_agents('edge')
37
+ end
30
38
 
31
- puts 'get edge UA...'
32
- edge
39
+ def ordered_user_agents
40
+ USER_AGENT_TYPES.to_h.values.each_with_object({}) do |type, ordered_user_agents|
41
+ ordered_user_agents[type] = user_agents[type]
42
+ end
33
43
  end
34
44
 
35
45
  private
36
46
 
47
+ def fetch_user_agents(browser_name, sleep_time = 1)
48
+ puts "fetch #{browser_name} UA..."
49
+ send(browser_name)
50
+ puts "sleeping... (#{sleep_time}s)"
51
+ sleep sleep_time
52
+ end
53
+
37
54
  def edge
38
55
  page = @agent.get("#{BASE_URL}/edge")
39
56
 
40
57
  windows_dom = page.css("h2:contains('Latest Edge on Windows User Agents')")
41
- @user_agents[:edge] = {
42
- windows: windows_dom.css('+ .listing-of-useragents .code').first.text
43
- }
58
+
59
+ @user_agents[USER_AGENT_TYPES.windows_edge] = windows_dom.css('+ .listing-of-useragents .code').first.text
44
60
  end
45
61
 
46
62
  def firefox
@@ -49,11 +65,9 @@ class LatestUAFetcher
49
65
  desktop_dom = page.css("h2:contains('Latest Firefox on Desktop User Agents')")
50
66
  table_dom = desktop_dom.css('+ .listing-of-useragents')
51
67
 
52
- @user_agents[:firefox] = {
53
- windows: table_dom.css('td:contains("Windows")').css('+ td .code').text,
54
- macOS: table_dom.css('td:contains("Macos")').css('+ td .code').text,
55
- linux: table_dom.css('td:contains("Linux")').css("+ td .code:contains('Ubuntu; Linux x86_64')").text
56
- }
68
+ @user_agents[USER_AGENT_TYPES.linux_firefox] = table_dom.css('td:contains("Linux")').css("+ td .code:contains('Ubuntu; Linux x86_64')").text
69
+ @user_agents[USER_AGENT_TYPES.windows_firefox] = table_dom.css('td:contains("Windows")').css('+ td .code').text
70
+ @user_agents[USER_AGENT_TYPES.mac_firefox] = table_dom.css('td:contains("Macos")').css('+ td .code').text
57
71
  end
58
72
 
59
73
  def safari
@@ -62,30 +76,25 @@ class LatestUAFetcher
62
76
  macos_dom = page.css("h2:contains('Latest Safari on macOS User Agents')")
63
77
  ios_dom = page.css("h2:contains('Latest Safari on iOS User Agents')")
64
78
 
65
- @user_agents[:safari] = {
66
- mac_os: macos_dom.css('+ .listing-of-useragents .code').first.text,
67
- iphone: ios_dom.css('+ .listing-of-useragents').css("tr:contains('Iphone') .code").text,
68
- ipad: ios_dom.css('+ .listing-of-useragents').css("tr:contains('Ipad') .code").text
69
- }
79
+ @user_agents[USER_AGENT_TYPES.mac_safari] = macos_dom.css('+ .listing-of-useragents .code').first.text
80
+ @user_agents[USER_AGENT_TYPES.iphone] = ios_dom.css('+ .listing-of-useragents').css("tr:contains('Iphone') .code").text
81
+ @user_agents[USER_AGENT_TYPES.ipad] = ios_dom.css('+ .listing-of-useragents').css("tr:contains('Ipad') .code").text
70
82
  end
71
83
 
72
84
  def chrome
73
85
  page = @agent.get("#{BASE_URL}/chrome")
74
86
 
75
87
  windows_dom = page.css("h2:contains('Latest Chrome on Windows 10 User Agents')")
76
- linux_dom = page.css("h2:contains('Latest Chrome on Linux User Agents')")
77
- macos_dom = page.css("h2:contains('Latest Chrome on macOS User Agents')")
78
88
  android_dom = page.css("h2:contains('Latest Chrome on Android User Agents')")
79
89
 
80
- @user_agents[:chrome] = {
81
- windows: windows_dom.css('+ .listing-of-useragents .code').first.text,
82
- linux: linux_dom.css('+ .listing-of-useragents .code').first.text,
83
- mac_os: macos_dom.css('+ .listing-of-useragents .code').first.text,
84
- android: android_dom.css('+ .listing-of-useragents .code').first.text
85
- }
90
+ @user_agents[USER_AGENT_TYPES.windows_chrome] = windows_dom.css('+ .listing-of-useragents .code').first.text
91
+ @user_agents[USER_AGENT_TYPES.android] = android_dom.css('+ .listing-of-useragents .code').first.text
86
92
  end
87
93
  end
88
94
 
89
- agent = LatestUAFetcher.new
90
- agent.run
91
- p agent.user_agents
95
+ if $0 == __FILE__
96
+ agent = LatestUAFetcher.new
97
+ agent.run
98
+
99
+ pp agent.ordered_user_agents
100
+ end
@@ -36,7 +36,7 @@ class Mechanize::Form::MultiSelectList < Mechanize::Form::Field
36
36
  # select_list.option_with(:value => '1').value = 'foo'
37
37
 
38
38
  ##
39
- # :mehtod: option_with!(criteria)
39
+ # :method: option_with!(criteria)
40
40
  #
41
41
  # Same as +option_with+ but raises an ElementNotFoundError if no button
42
42
  # matches +criteria+
@@ -482,7 +482,7 @@ class Mechanize::Form
482
482
  # form.file_upload_with(:file_name => /picture/).value = 'foo'
483
483
 
484
484
  ##
485
- # :mehtod: file_upload_with!(criteria)
485
+ # :method: file_upload_with!(criteria)
486
486
  #
487
487
  # Same as +file_upload_with+ but raises an ElementNotFoundError if no button
488
488
  # matches +criteria+
@@ -506,7 +506,7 @@ class Mechanize::Form
506
506
  # form.radiobutton_with(:name => /woo/).check
507
507
 
508
508
  ##
509
- # :mehtod: radiobutton_with!(criteria)
509
+ # :method: radiobutton_with!(criteria)
510
510
  #
511
511
  # Same as +radiobutton_with+ but raises an ElementNotFoundError if no button
512
512
  # matches +criteria+
@@ -530,7 +530,7 @@ class Mechanize::Form
530
530
  # form.checkbox_with(:name => /woo/).check
531
531
 
532
532
  ##
533
- # :mehtod: checkbox_with!(criteria)
533
+ # :method: checkbox_with!(criteria)
534
534
  #
535
535
  # Same as +checkbox_with+ but raises an ElementNotFoundError if no button
536
536
  # matches +criteria+
@@ -66,7 +66,7 @@ class Mechanize::HTTP::Agent
66
66
  # allowed:
67
67
  #
68
68
  # :all, true:: All 3xx redirects are followed (default)
69
- # :permanent:: Only 301 Moved Permanantly redirects are followed
69
+ # :permanent:: Only 301 Moved Permanently redirects are followed
70
70
  # false:: No redirects are followed
71
71
  attr_accessor :redirect_ok
72
72
 
@@ -81,7 +81,7 @@ class Mechanize::HTTP::ContentDispositionParser
81
81
  end
82
82
 
83
83
  ##
84
- # Extracts disposition-parm and returns a Hash.
84
+ # Extracts disposition-param and returns a Hash.
85
85
 
86
86
  def parse_parameters
87
87
  parameters = {}
@@ -200,4 +200,3 @@ class Mechanize::HTTP::ContentDispositionParser
200
200
  end
201
201
 
202
202
  end
203
-
@@ -95,7 +95,7 @@ class Mechanize::Page < Mechanize::File
95
95
  end
96
96
 
97
97
  # Return whether parser result has errors related to encoding or not.
98
- # false indicates just parser has no encoding errors, not encoding is vaild.
98
+ # false indicates just parser has no encoding errors, not encoding is valid.
99
99
  def encoding_error?(parser=nil)
100
100
  parser = self.parser unless parser
101
101
  return false if parser.errors.empty?
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Mechanize
3
- VERSION = "2.9.1"
3
+ VERSION = "2.9.2"
4
4
  end
data/lib/mechanize.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  require 'mechanize/version'
3
3
  require 'fileutils'
4
4
  require 'forwardable'
5
- require 'mutex_m'
6
5
  require 'net/http/digest_auth'
7
6
  require 'net/http/persistent'
8
7
  require 'nokogiri'
@@ -106,6 +105,7 @@ class Mechanize
106
105
  #
107
106
  # Windows User-Agent aliases:
108
107
  #
108
+ # * "Windows Chrome"
109
109
  # * "Windows Edge"
110
110
  # * "Windows Firefox"
111
111
  # * "Windows IE 6"
@@ -128,21 +128,20 @@ class Mechanize
128
128
  # agent.user_agent_alias = 'Mac Safari'
129
129
  #
130
130
  AGENT_ALIASES = {
131
- # TODO: use output from examples/latest_user_agents.rb as the underling data structure
132
131
  'Mechanize' => "Mechanize/#{VERSION} Ruby/#{ruby_version} (http://github.com/sparklemotion/mechanize/)",
133
132
 
134
- 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:112.0) Gecko/20100101 Firefox/112.0',
133
+ 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/121.0',
135
134
  'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
136
135
  'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
137
136
 
138
- 'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.3; rv:112.0) Gecko/20100101 Firefox/112.0',
137
+ 'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:109.0) Gecko/20100101 Firefox/121.0',
139
138
  'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
140
139
  'Mac Safari 4' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-at) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10',
141
- 'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
140
+ 'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15',
142
141
 
143
- 'Windows Chrome' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
144
- 'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.46',
145
- 'Windows Firefox' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) Gecko/20100101 Firefox/112.0',
142
+ 'Windows Chrome' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
143
+ 'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.2210.133',
144
+ 'Windows Firefox' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0',
146
145
  'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
147
146
  'Windows IE 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
148
147
  'Windows IE 8' => 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
@@ -151,9 +150,9 @@ class Mechanize
151
150
  'Windows IE 11' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
152
151
  'Windows Mozilla' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6',
153
152
 
154
- 'Android' => 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.48 Mobile Safari/537.36',
155
- 'iPad' => 'Mozilla/5.0 (iPad; CPU OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1',
156
- 'iPhone' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1',
153
+ 'Android' => 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.210 Mobile Safari/537.36',
154
+ 'iPad' => 'Mozilla/5.0 (iPad; CPU OS 17_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1',
155
+ 'iPhone' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1',
157
156
  }
158
157
 
159
158
  AGENT_ALIASES.default_proc = proc { |hash, key|
@@ -201,7 +200,7 @@ class Mechanize
201
200
  #
202
201
  # If you need segregated SSL connections give each agent a unique
203
202
  # name. Otherwise the connections will be shared. This is
204
- # particularly important if you are using certifcates.
203
+ # particularly important if you are using certificates.
205
204
  #
206
205
  # agent_1 = Mechanize.new 'conn1'
207
206
  # agent_2 = Mechanize.new 'conn2'
@@ -957,7 +956,7 @@ Use of #auth and #basic_auth are deprecated due to a security vulnerability.
957
956
  # allowed:
958
957
  #
959
958
  # :all, true:: All 3xx redirects are followed (default)
960
- # :permanent:: Only 301 Moved Permanantly redirects are followed
959
+ # :permanent:: Only 301 Moved Permanently redirects are followed
961
960
  # false:: No redirects are followed
962
961
 
963
962
  def redirect_ok
@@ -540,7 +540,7 @@ class TestMechanizeCookieJar < Mechanize::TestCase
540
540
 
541
541
  @jar.add url, Mechanize::Cookie.new(cookie_values)
542
542
 
543
- # HACK no asertion
543
+ # HACK no assertion
544
544
  end
545
545
 
546
546
  def test_ssl_cookies
@@ -357,7 +357,7 @@ class TestMechanizeForm < Mechanize::TestCase
357
357
  assert_equal 'ticky=1&ticky=0', submitted.parser.at('#query').text
358
358
  end
359
359
 
360
- def test_submit_takes_arbirary_headers
360
+ def test_submit_takes_arbitrary_headers
361
361
  page = @mech.get('http://localhost:2000/form_no_action.html')
362
362
  assert form = page.forms.first
363
363
  form.action = '/http_headers'
@@ -1309,8 +1309,13 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1309
1309
  page = @agent.response_parse @res, body, @uri
1310
1310
 
1311
1311
  assert_instance_of Mechanize::Page, page
1312
- assert_equal 'UTF8', page.encoding
1313
- assert_equal 'UTF8', page.parser.encoding
1312
+
1313
+ # as of libxml 2.12.0, the result is dependent on how libiconv is built (which aliases are supported)
1314
+ # if the alias "UTF8" is defined, then the result will be "UTF-8".
1315
+ # if the alias "UTF8" is not defined, then the result will be "UTF8".
1316
+ # note that this alias may be defined by Nokogiri itself in its EncodingHandler class.
1317
+ assert_includes ["UTF8", "UTF-8"], page.encoding
1318
+ assert_includes ["UTF8", "UTF-8"], page.parser.encoding
1314
1319
  end
1315
1320
 
1316
1321
  def test_response_parse_content_type_encoding_garbage
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'mechanize/test_case'
4
4
 
5
+ puts "Nokogiri::VERSION_INFO: #{Nokogiri::VERSION_INFO}"
6
+
5
7
  class TestMechanizePageLink < Mechanize::TestCase
6
8
 
7
9
  WINDOWS_1255 = <<-HTML
@@ -111,11 +113,15 @@ class TestMechanizePageLink < Mechanize::TestCase
111
113
  def test_encoding_charset_after_title_bad
112
114
  skip_if_nkf_dependency
113
115
 
116
+ # https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
117
+ skip if Nokogiri.uses_libxml?([">= 2.11.0", "< 2.12.0"])
118
+ expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'
119
+
114
120
  page = util_page UTF8
115
121
 
116
122
  assert_equal false, page.encoding_error?
117
123
 
118
- assert_equal 'UTF-8', page.encoding
124
+ assert_equal expected_encoding, page.encoding
119
125
  end
120
126
 
121
127
  def test_encoding_charset_after_title_double_bad
@@ -131,6 +137,10 @@ class TestMechanizePageLink < Mechanize::TestCase
131
137
  def test_encoding_charset_bad
132
138
  skip_if_nkf_dependency
133
139
 
140
+ # https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
141
+ skip if Nokogiri.uses_libxml?([">= 2.11.0", "< 2.12.0"])
142
+ expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'
143
+
134
144
  page = util_page "<title>#{UTF8_TITLE}</title>"
135
145
  page.encodings.replace %w[
136
146
  UTF-8
@@ -139,7 +149,7 @@ class TestMechanizePageLink < Mechanize::TestCase
139
149
 
140
150
  assert_equal false, page.encoding_error?
141
151
 
142
- assert_equal 'UTF-8', page.encoding
152
+ assert_equal expected_encoding, page.encoding
143
153
  end
144
154
 
145
155
  def test_encoding_meta_charset
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-04-17 00:00:00.000000000 Z
15
+ date: 2024-01-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -503,7 +503,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
503
  - !ruby/object:Gem::Version
504
504
  version: '0'
505
505
  requirements: []
506
- rubygems_version: 3.4.10
506
+ rubygems_version: 3.4.19
507
507
  signing_key:
508
508
  specification_version: 4
509
509
  summary: The Mechanize library is used for automating interaction with websites