mechanize 2.9.0 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci-test.yml +4 -3
- data/CHANGELOG.md +22 -9
- data/examples/latest_user_agents.rb +100 -0
- data/lib/mechanize/form/multi_select_list.rb +1 -1
- data/lib/mechanize/form.rb +3 -3
- data/lib/mechanize/http/agent.rb +1 -1
- data/lib/mechanize/http/content_disposition_parser.rb +1 -2
- data/lib/mechanize/page.rb +1 -1
- data/lib/mechanize/version.rb +1 -1
- data/lib/mechanize.rb +51 -33
- data/test/test_mechanize_cookie_jar.rb +1 -1
- data/test/test_mechanize_form.rb +1 -1
- data/test/test_mechanize_http_agent.rb +7 -2
- data/test/test_mechanize_page_link.rb +12 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 657e0dcff19a6db26a52cf94584a987b9cd231bee579fc10662b0ef677716a68
|
4
|
+
data.tar.gz: 2f706289ddcdf0090303f0bdcf9771ea3d4547b4d31f1c0ab31ac930bc25485c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,18 @@
|
|
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
|
+
|
9
|
+
## 2.9.1 / 2023-04-17
|
10
|
+
|
11
|
+
### Update
|
12
|
+
|
13
|
+
* Updated User-Agent strings to represent modern browser versions. (#612) Thank you, @takatea!
|
14
|
+
|
15
|
+
|
3
16
|
## 2.9.0 / 2023-04-07
|
4
17
|
|
5
18
|
### Requirements
|
@@ -102,7 +115,7 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
|
|
102
115
|
* Fix element(s)_with(search: selector) methods not working for forms, form fields and frames. (#444)
|
103
116
|
* Improve the filename parser for the `Content-Disposition` header. (#496, #517)
|
104
117
|
* Accept `Content-Encoding: identity`. (#515)
|
105
|
-
* Mechanize::Page#title no longer picks a title in an
|
118
|
+
* Mechanize::Page#title no longer picks a title in an embedded SVG/RDF element. (#503)
|
106
119
|
* Make Mechanize::Form#has_field? boolean. (#501)
|
107
120
|
|
108
121
|
## 2.7.5
|
@@ -408,8 +421,8 @@ Fixes low-severity CVE-2022-31033, "Authorization header leak on port redirect."
|
|
408
421
|
* When given multiple HTTP authentication options mechanize now picks the
|
409
422
|
strongest method.
|
410
423
|
* Improvements to HTTP authorization:
|
411
|
-
* mechanize raises Mechanize::
|
412
|
-
a
|
424
|
+
* mechanize raises Mechanize::UnauthorizedError for 401 responses which is
|
425
|
+
a subclass of Mechanize::ResponseCodeError.
|
413
426
|
* Added support for NTLM authentication, but this has not been tested.
|
414
427
|
* Mechanize::Cookie.new accepts attributes in a hash.
|
415
428
|
* Mechanize::CookieJar#<<(cookie) (alias: add!) is added. Issue #139
|
@@ -500,7 +513,7 @@ Mechanize is now under the MIT license
|
|
500
513
|
|
501
514
|
* New Features
|
502
515
|
|
503
|
-
* Add header reference methods to Mechanize::File so that a
|
516
|
+
* Add header reference methods to Mechanize::File so that a response
|
504
517
|
object gets compatible with Net::HTTPResponse.
|
505
518
|
* Mechanize#click accepts a regexp or string to click a button/link in the
|
506
519
|
current page. It works as expected when not passed a string or regexp.
|
@@ -725,7 +738,7 @@ Mechanize is now under the MIT license
|
|
725
738
|
http://d.hatena.ne.jp/kitamomonga/20080410/ruby_mechanize_percent_url_bug
|
726
739
|
* #21132 Not checking for EOF errors on redirect
|
727
740
|
* Fixed a weird gzipping error.
|
728
|
-
* #21233 Smarter multipart
|
741
|
+
* #21233 Smarter multipart boundary. Thanks Todd Willey!
|
729
742
|
* #20097 Supporting meta tag cookies.
|
730
743
|
|
731
744
|
## 0.7.6
|
@@ -834,7 +847,7 @@ Mechanize is now under the MIT license
|
|
834
847
|
* [#9877] Moved last request time. Thanks Max Stepanov
|
835
848
|
* Added WWW::Mechanize::File#save
|
836
849
|
* Defaulting file name to URI or Content-Disposition
|
837
|
-
* Updating
|
850
|
+
* Updating compatibility with hpricot
|
838
851
|
* Added more unit tests
|
839
852
|
|
840
853
|
## 0.6.7
|
@@ -846,7 +859,7 @@ Mechanize is now under the MIT license
|
|
846
859
|
|
847
860
|
* Removing hpricot overrides
|
848
861
|
* Fixed a bug where alt text can be nil. Thanks Yannick!
|
849
|
-
*
|
862
|
+
* Unparsable expiration dates in cookies are now treated as session cookies
|
850
863
|
* Caching connections
|
851
864
|
* Requests now default to keep alive
|
852
865
|
* [#9434] Fixed bug where html entities weren't decoded
|
@@ -912,7 +925,7 @@ Mechanize is now under the MIT license
|
|
912
925
|
* Added a method to Form called "submit". Now forms can be submitted by
|
913
926
|
calling a method on the form.
|
914
927
|
* Added a click method to links
|
915
|
-
* Added an REXML pluggable parser for backwards
|
928
|
+
* Added an REXML pluggable parser for backwards compatibility. To use it,
|
916
929
|
just do this:
|
917
930
|
agent.pluggable_parser.html = WWW::Mechanize::REXMLPage
|
918
931
|
* Fixed a bug with referrers by adding a page attribute to forms and links.
|
@@ -1039,7 +1052,7 @@ Mechanize is now under the MIT license
|
|
1039
1052
|
|
1040
1053
|
## 0.4.4
|
1041
1054
|
|
1042
|
-
* Fixed error in method signature,
|
1055
|
+
* Fixed error in method signature, basic_authentication is now basic_auth
|
1043
1056
|
* Fixed bug with encoding names in file uploads (Big thanks to Alex Young)
|
1044
1057
|
* Added options to the select list
|
1045
1058
|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
# LatestUAFetcher fetches latest user agents from `WhatIsMyBrowser.com`.
|
5
|
+
# It can use to update `Mechanize::AGENT_ALIASES`.
|
6
|
+
class LatestUAFetcher
|
7
|
+
attr_reader :user_agents
|
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
|
+
|
21
|
+
BASE_URL = 'https://www.whatismybrowser.com/guides/the-latest-user-agent'
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@agent = Mechanize.new.tap { |a| a.user_agent_alias = 'Mac Firefox' }
|
25
|
+
@user_agents = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
return unless user_agents.empty?
|
30
|
+
|
31
|
+
sleep_time = 1
|
32
|
+
|
33
|
+
fetch_user_agents('chrome')
|
34
|
+
fetch_user_agents('firefox')
|
35
|
+
fetch_user_agents('safari')
|
36
|
+
fetch_user_agents('edge')
|
37
|
+
end
|
38
|
+
|
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
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
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
|
+
|
54
|
+
def edge
|
55
|
+
page = @agent.get("#{BASE_URL}/edge")
|
56
|
+
|
57
|
+
windows_dom = page.css("h2:contains('Latest Edge on Windows User Agents')")
|
58
|
+
|
59
|
+
@user_agents[USER_AGENT_TYPES.windows_edge] = windows_dom.css('+ .listing-of-useragents .code').first.text
|
60
|
+
end
|
61
|
+
|
62
|
+
def firefox
|
63
|
+
page = @agent.get("#{BASE_URL}/firefox")
|
64
|
+
|
65
|
+
desktop_dom = page.css("h2:contains('Latest Firefox on Desktop User Agents')")
|
66
|
+
table_dom = desktop_dom.css('+ .listing-of-useragents')
|
67
|
+
|
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
|
71
|
+
end
|
72
|
+
|
73
|
+
def safari
|
74
|
+
page = @agent.get("#{BASE_URL}/safari")
|
75
|
+
|
76
|
+
macos_dom = page.css("h2:contains('Latest Safari on macOS User Agents')")
|
77
|
+
ios_dom = page.css("h2:contains('Latest Safari on iOS User Agents')")
|
78
|
+
|
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
|
82
|
+
end
|
83
|
+
|
84
|
+
def chrome
|
85
|
+
page = @agent.get("#{BASE_URL}/chrome")
|
86
|
+
|
87
|
+
windows_dom = page.css("h2:contains('Latest Chrome on Windows 10 User Agents')")
|
88
|
+
android_dom = page.css("h2:contains('Latest Chrome on Android User Agents')")
|
89
|
+
|
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
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
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
|
-
# :
|
39
|
+
# :method: option_with!(criteria)
|
40
40
|
#
|
41
41
|
# Same as +option_with+ but raises an ElementNotFoundError if no button
|
42
42
|
# matches +criteria+
|
data/lib/mechanize/form.rb
CHANGED
@@ -482,7 +482,7 @@ class Mechanize::Form
|
|
482
482
|
# form.file_upload_with(:file_name => /picture/).value = 'foo'
|
483
483
|
|
484
484
|
##
|
485
|
-
# :
|
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
|
-
# :
|
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
|
-
# :
|
533
|
+
# :method: checkbox_with!(criteria)
|
534
534
|
#
|
535
535
|
# Same as +checkbox_with+ but raises an ElementNotFoundError if no button
|
536
536
|
# matches +criteria+
|
data/lib/mechanize/http/agent.rb
CHANGED
@@ -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
|
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-
|
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
|
-
|
data/lib/mechanize/page.rb
CHANGED
@@ -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
|
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?
|
data/lib/mechanize/version.rb
CHANGED
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'
|
@@ -87,54 +86,73 @@ class Mechanize
|
|
87
86
|
# description in parenthesis is for informative purposes and is not part of
|
88
87
|
# the alias name.
|
89
88
|
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
# *
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
# *
|
97
|
-
# *
|
98
|
-
# *
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
# *
|
103
|
-
# *
|
104
|
-
# *
|
105
|
-
# *
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# *
|
89
|
+
# The default User-Agent alias:
|
90
|
+
#
|
91
|
+
# * "Mechanize"
|
92
|
+
#
|
93
|
+
# Linux User-Agent aliases:
|
94
|
+
#
|
95
|
+
# * "Linux Firefox"
|
96
|
+
# * "Linux Konqueror"
|
97
|
+
# * "Linux Mozilla"
|
98
|
+
#
|
99
|
+
# Mac User-Agent aliases:
|
100
|
+
#
|
101
|
+
# * "Mac Firefox"
|
102
|
+
# * "Mac Mozilla"
|
103
|
+
# * "Mac Safari 4"
|
104
|
+
# * "Mac Safari"
|
105
|
+
#
|
106
|
+
# Windows User-Agent aliases:
|
107
|
+
#
|
108
|
+
# * "Windows Chrome"
|
109
|
+
# * "Windows Edge"
|
110
|
+
# * "Windows Firefox"
|
111
|
+
# * "Windows IE 6"
|
112
|
+
# * "Windows IE 7"
|
113
|
+
# * "Windows IE 8"
|
114
|
+
# * "Windows IE 9"
|
115
|
+
# * "Windows IE 10"
|
116
|
+
# * "Windows IE 11"
|
117
|
+
# * "Windows Mozilla"
|
118
|
+
#
|
119
|
+
# Mobile User-Agent aliases:
|
120
|
+
#
|
121
|
+
# * "Android"
|
122
|
+
# * "iPad"
|
123
|
+
# * "iPhone"
|
110
124
|
#
|
111
125
|
# Example:
|
112
126
|
#
|
113
127
|
# agent = Mechanize.new
|
114
128
|
# agent.user_agent_alias = 'Mac Safari'
|
115
|
-
|
129
|
+
#
|
116
130
|
AGENT_ALIASES = {
|
117
131
|
'Mechanize' => "Mechanize/#{VERSION} Ruby/#{ruby_version} (http://github.com/sparklemotion/mechanize/)",
|
118
|
-
|
132
|
+
|
133
|
+
'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/121.0',
|
119
134
|
'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
|
120
135
|
'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
|
121
|
-
|
136
|
+
|
137
|
+
'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:109.0) Gecko/20100101 Firefox/121.0',
|
122
138
|
'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
|
123
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',
|
124
|
-
'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X
|
125
|
-
|
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',
|
141
|
+
|
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',
|
126
145
|
'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
|
127
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)',
|
128
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)',
|
129
148
|
'Windows IE 9' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
|
130
149
|
'Windows IE 10' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)',
|
131
150
|
'Windows IE 11' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
|
132
|
-
'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586',
|
133
151
|
'Windows Mozilla' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6',
|
134
|
-
|
135
|
-
'
|
136
|
-
'iPad' => 'Mozilla/5.0 (iPad; CPU OS
|
137
|
-
'
|
152
|
+
|
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',
|
138
156
|
}
|
139
157
|
|
140
158
|
AGENT_ALIASES.default_proc = proc { |hash, key|
|
@@ -182,7 +200,7 @@ class Mechanize
|
|
182
200
|
#
|
183
201
|
# If you need segregated SSL connections give each agent a unique
|
184
202
|
# name. Otherwise the connections will be shared. This is
|
185
|
-
# particularly important if you are using
|
203
|
+
# particularly important if you are using certificates.
|
186
204
|
#
|
187
205
|
# agent_1 = Mechanize.new 'conn1'
|
188
206
|
# agent_2 = Mechanize.new 'conn2'
|
@@ -938,7 +956,7 @@ Use of #auth and #basic_auth are deprecated due to a security vulnerability.
|
|
938
956
|
# allowed:
|
939
957
|
#
|
940
958
|
# :all, true:: All 3xx redirects are followed (default)
|
941
|
-
# :permanent:: Only 301 Moved
|
959
|
+
# :permanent:: Only 301 Moved Permanently redirects are followed
|
942
960
|
# false:: No redirects are followed
|
943
961
|
|
944
962
|
def redirect_ok
|
data/test/test_mechanize_form.rb
CHANGED
@@ -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
|
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
|
-
|
1313
|
-
|
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
|
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
|
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.
|
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:
|
15
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: addressable
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- README.md
|
280
280
|
- Rakefile
|
281
281
|
- examples/flickr_upload.rb
|
282
|
+
- examples/latest_user_agents.rb
|
282
283
|
- examples/mech-dump.rb
|
283
284
|
- examples/proxy_req.rb
|
284
285
|
- examples/rubygems.rb
|
@@ -502,7 +503,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
502
503
|
- !ruby/object:Gem::Version
|
503
504
|
version: '0'
|
504
505
|
requirements: []
|
505
|
-
rubygems_version: 3.4.
|
506
|
+
rubygems_version: 3.4.19
|
506
507
|
signing_key:
|
507
508
|
specification_version: 4
|
508
509
|
summary: The Mechanize library is used for automating interaction with websites
|