mechanize 2.9.1 → 2.10.0

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: 9dcbcae38bd4674eb12e4cc7cf33e85d97177ef6aa2d3cd975e2b899178faa54
4
+ data.tar.gz: 7753407c594d4d063f061680ee0037a7605354c2c79dc767d241105500f9ced1
5
5
  SHA512:
6
- metadata.gz: a11a74bb5118f20cd4a31673f40595882192b8c84d33d6bf6d116e007afe6e369ce7ae7f1dc832f34a94d6dc7a2732c82462351f62b53bdaab0ed6bcf2ea8bd6
7
- data.tar.gz: 2bc5af7fb18fcdffa84f255777317f1729b454dc3f8539de27ad172991c49c250de457464691d63c85c32006ecb4105137b653f1c78ea948425e54aa562b2b98
6
+ metadata.gz: fc0c85ef0897b1ef9aff7ff29b9e158ba9d785e2e86e758542d533664c0d168f56823c9946b9243eb7eaad57e294af8fe8d7d1a5f717da15466a45d63597ee76
7
+ data.tar.gz: 9f398d164b6ddc0de22301f73cf24d1d37fb68e4a7df427cad3924fac6424f35a089a0d675c6b498bfc9a28f55e1b1842c9d3356e0ac27edf5f884221b0549c3
@@ -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", "jruby-9.4", "truffleruby", "head", "jruby-head", "truffleruby-head"]
35
36
 
36
37
  runs-on: ubuntu-latest
37
38
  steps:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Mechanize CHANGELOG
2
2
 
3
+ ## 2.10.0 / 2024-01-22
4
+
5
+ * Add `nkf` and `base64` as explicit dependencies, since they are being unbundled in Ruby 3.4. (#634) @flavorjones
6
+
7
+
8
+ ## 2.9.2 / 2024-01-15
9
+
10
+ * Correct spelling errors in documentation. (#631) @p-linnane
11
+ * Updated User-Agent strings to represent modern browser versions. (#632) @takatea
12
+
13
+
3
14
  ## 2.9.1 / 2023-04-17
4
15
 
5
16
  ### Update
@@ -109,7 +120,7 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
109
120
  * Fix element(s)_with(search: selector) methods not working for forms, form fields and frames. (#444)
110
121
  * Improve the filename parser for the `Content-Disposition` header. (#496, #517)
111
122
  * Accept `Content-Encoding: identity`. (#515)
112
- * Mechanize::Page#title no longer picks a title in an embeded SVG/RDF element. (#503)
123
+ * Mechanize::Page#title no longer picks a title in an embedded SVG/RDF element. (#503)
113
124
  * Make Mechanize::Form#has_field? boolean. (#501)
114
125
 
115
126
  ## 2.7.5
@@ -415,8 +426,8 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
415
426
  * When given multiple HTTP authentication options mechanize now picks the
416
427
  strongest method.
417
428
  * Improvements to HTTP authorization:
418
- * mechanize raises Mechanize::UnathorizedError for 401 responses which is
419
- a sublcass of Mechanize::ResponseCodeError.
429
+ * mechanize raises Mechanize::UnauthorizedError for 401 responses which is
430
+ a subclass of Mechanize::ResponseCodeError.
420
431
  * Added support for NTLM authentication, but this has not been tested.
421
432
  * Mechanize::Cookie.new accepts attributes in a hash.
422
433
  * Mechanize::CookieJar#<<(cookie) (alias: add!) is added. Issue #139
@@ -507,7 +518,7 @@ Mechanize is now under the MIT license
507
518
 
508
519
  * New Features
509
520
 
510
- * Add header reference methods to Mechanize::File so that a reponse
521
+ * Add header reference methods to Mechanize::File so that a response
511
522
  object gets compatible with Net::HTTPResponse.
512
523
  * Mechanize#click accepts a regexp or string to click a button/link in the
513
524
  current page. It works as expected when not passed a string or regexp.
@@ -732,7 +743,7 @@ Mechanize is now under the MIT license
732
743
  http://d.hatena.ne.jp/kitamomonga/20080410/ruby_mechanize_percent_url_bug
733
744
  * #21132 Not checking for EOF errors on redirect
734
745
  * Fixed a weird gzipping error.
735
- * #21233 Smarter multipart boundry. Thanks Todd Willey!
746
+ * #21233 Smarter multipart boundary. Thanks Todd Willey!
736
747
  * #20097 Supporting meta tag cookies.
737
748
 
738
749
  ## 0.7.6
@@ -841,7 +852,7 @@ Mechanize is now under the MIT license
841
852
  * [#9877] Moved last request time. Thanks Max Stepanov
842
853
  * Added WWW::Mechanize::File#save
843
854
  * Defaulting file name to URI or Content-Disposition
844
- * Updating compatability with hpricot
855
+ * Updating compatibility with hpricot
845
856
  * Added more unit tests
846
857
 
847
858
  ## 0.6.7
@@ -853,7 +864,7 @@ Mechanize is now under the MIT license
853
864
 
854
865
  * Removing hpricot overrides
855
866
  * Fixed a bug where alt text can be nil. Thanks Yannick!
856
- * Unparseable expiration dates in cookies are now treated as session cookies
867
+ * Unparsable expiration dates in cookies are now treated as session cookies
857
868
  * Caching connections
858
869
  * Requests now default to keep alive
859
870
  * [#9434] Fixed bug where html entities weren't decoded
@@ -919,7 +930,7 @@ Mechanize is now under the MIT license
919
930
  * Added a method to Form called "submit". Now forms can be submitted by
920
931
  calling a method on the form.
921
932
  * Added a click method to links
922
- * Added an REXML pluggable parser for backwards compatability. To use it,
933
+ * Added an REXML pluggable parser for backwards compatibility. To use it,
923
934
  just do this:
924
935
  agent.pluggable_parser.html = WWW::Mechanize::REXMLPage
925
936
  * Fixed a bug with referrers by adding a page attribute to forms and links.
@@ -1046,7 +1057,7 @@ Mechanize is now under the MIT license
1046
1057
 
1047
1058
  ## 0.4.4
1048
1059
 
1049
- * Fixed error in method signature, basic_authetication is now basic_auth
1060
+ * Fixed error in method signature, basic_authentication is now basic_auth
1050
1061
  * Fixed bug with encoding names in file uploads (Big thanks to Alex Young)
1051
1062
  * Added options to the select list
1052
1063
 
@@ -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.10.0"
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
data/mechanize.gemspec CHANGED
@@ -65,10 +65,13 @@ Gem::Specification.new do |spec|
65
65
  spec.add_runtime_dependency("net-http-persistent", ">= 2.5.2", "< 5.0.dev")
66
66
 
67
67
  spec.add_runtime_dependency("nokogiri", ">= 1.11.2", "~> 1.11")
68
- spec.add_runtime_dependency("rubyntlm", ">= 0.6.3", "~> 0.6")
69
68
  spec.add_runtime_dependency("webrick", "~> 1.7")
70
69
  spec.add_runtime_dependency("webrobots", "~> 0.1.2")
71
70
 
71
+ spec.add_runtime_dependency("rubyntlm", ">= 0.6.3", "~> 0.6")
72
+ spec.add_runtime_dependency("base64") # removed from bundled gems in 3.4, and needed by rubyntlm (which doesn't declare this dependency)
73
+ spec.add_runtime_dependency("nkf") # removed from bundled gems in 3.4
74
+
72
75
  spec.add_development_dependency("minitest", "~> 5.14")
73
76
  spec.add_development_dependency("rake", "~> 13.0")
74
77
  spec.add_development_dependency("rdoc", "~> 6.3")
@@ -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.10.0
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-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -142,6 +142,34 @@ dependencies:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
144
  version: '1.11'
145
+ - !ruby/object:Gem::Dependency
146
+ name: webrick
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '1.7'
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '1.7'
159
+ - !ruby/object:Gem::Dependency
160
+ name: webrobots
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: 0.1.2
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: 0.1.2
145
173
  - !ruby/object:Gem::Dependency
146
174
  name: rubyntlm
147
175
  requirement: !ruby/object:Gem::Requirement
@@ -163,33 +191,33 @@ dependencies:
163
191
  - !ruby/object:Gem::Version
164
192
  version: '0.6'
165
193
  - !ruby/object:Gem::Dependency
166
- name: webrick
194
+ name: base64
167
195
  requirement: !ruby/object:Gem::Requirement
168
196
  requirements:
169
- - - "~>"
197
+ - - ">="
170
198
  - !ruby/object:Gem::Version
171
- version: '1.7'
199
+ version: '0'
172
200
  type: :runtime
173
201
  prerelease: false
174
202
  version_requirements: !ruby/object:Gem::Requirement
175
203
  requirements:
176
- - - "~>"
204
+ - - ">="
177
205
  - !ruby/object:Gem::Version
178
- version: '1.7'
206
+ version: '0'
179
207
  - !ruby/object:Gem::Dependency
180
- name: webrobots
208
+ name: nkf
181
209
  requirement: !ruby/object:Gem::Requirement
182
210
  requirements:
183
- - - "~>"
211
+ - - ">="
184
212
  - !ruby/object:Gem::Version
185
- version: 0.1.2
213
+ version: '0'
186
214
  type: :runtime
187
215
  prerelease: false
188
216
  version_requirements: !ruby/object:Gem::Requirement
189
217
  requirements:
190
- - - "~>"
218
+ - - ">="
191
219
  - !ruby/object:Gem::Version
192
- version: 0.1.2
220
+ version: '0'
193
221
  - !ruby/object:Gem::Dependency
194
222
  name: minitest
195
223
  requirement: !ruby/object:Gem::Requirement
@@ -503,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
531
  - !ruby/object:Gem::Version
504
532
  version: '0'
505
533
  requirements: []
506
- rubygems_version: 3.4.10
534
+ rubygems_version: 3.5.5
507
535
  signing_key:
508
536
  specification_version: 4
509
537
  summary: The Mechanize library is used for automating interaction with websites