mechanize 2.8.0 → 2.8.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mechanize might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7df2fdd2030e028d6107b3b54f94f788deba04b9615cb719ef2113291270d1c
4
- data.tar.gz: ab12e971c446e5977662076f39711298b5311ef12fe54612855433e5e926fa46
3
+ metadata.gz: d8b4e424716d3f5d8fdc1fe82efca4412eee6b414c0cafee9cdced96023e632d
4
+ data.tar.gz: b4450930235cb304ced9e63cede8fd3abe3bc7c7f38530ef6127be8208de3c93
5
5
  SHA512:
6
- metadata.gz: 50f065469eb756a860e5c02b6e2d31cd5f25e0da2db9c4e9dddd018a96fb8fe4bb209ffd70c0e51c777ede12245faff86568a9e9044dd006d61d3514cd35660c
7
- data.tar.gz: 6db1eaffd62dc89449721ad9d06dbc5d0f8d15f24b49cf9be84a3f88dc1bd91a41e1774aef12bdc9933e3b8e0d5b0050cf4dbaa675db6131f7723b3713921630
6
+ metadata.gz: cb936d26c46330432cd5d230b5e54b3792de5a2e39d3aa3a09a4904e5cf0f4bd9547c489772f3cd8d989e171022a18943bf4d09f0420038ed36d941978605a4f
7
+ data.tar.gz: 3b8103cfa2759f937b43384ac13ae0b8be9d22505841199fd0acd8fc0f4c4d86e0844571bbcd930da2d55e54f2178bbe222f9876959851ee694988bd5b874668
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
@@ -10,36 +10,44 @@ on:
10
10
  - main
11
11
 
12
12
  jobs:
13
+ rubocop:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: "3.1"
20
+ bundler-cache: true
21
+ - run: bundle exec rake rubocop
22
+
13
23
  test:
24
+ needs: ["rubocop"]
14
25
  strategy:
15
26
  fail-fast: false
16
27
  matrix:
17
- ruby-version: ["2.5", "2.6", "2.7", "3.0", "jruby"]
28
+ ruby-version: ["2.5", "2.6", "2.7", "3.0", "3.1", "head", "jruby", "truffleruby-head"]
18
29
 
19
30
  runs-on: ubuntu-latest
20
31
  steps:
21
32
  - uses: actions/checkout@v2
22
- - name: Set up Ruby
23
- uses: ruby/setup-ruby@v1
33
+ - uses: ruby/setup-ruby@v1
24
34
  with:
25
- ruby-version: ${{ matrix.ruby-version }}
35
+ ruby-version: ${{matrix.ruby-version}}
26
36
  bundler-cache: true
27
- - name: Run tests
28
- run: bundle exec rake
37
+ - run: bundle exec rake test
29
38
 
30
39
  test-platform:
40
+ needs: ["rubocop"]
31
41
  strategy:
32
42
  fail-fast: false
33
43
  matrix:
34
44
  platform: ["windows-latest", "macos-latest"]
35
45
 
36
- runs-on: ${{ matrix.platform }}
46
+ runs-on: ${{matrix.platform}}
37
47
  steps:
38
48
  - uses: actions/checkout@v2
39
- - name: Set up Ruby
40
- uses: ruby/setup-ruby@v1
49
+ - uses: ruby/setup-ruby@v1
41
50
  with:
42
- ruby-version: 3.0
51
+ ruby-version: "3.1"
43
52
  bundler-cache: true
44
- - name: Run tests
45
- run: bundle exec rake
53
+ - run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,19 +1,51 @@
1
1
  # Mechanize CHANGELOG
2
2
 
3
+ ## 2.8.4 / 2022-01-17
4
+
5
+ ### Fix
6
+
7
+ * `Mechanize::CookieJar#load` calls `Psych.safe_load` when using Psych >= 3.1
8
+
9
+
10
+ ## 2.8.3 / 2021-11-11
11
+
12
+ ### Update
13
+
14
+ * Update the "Linux Firefox" user agent string to rev94 (#587) Thank you, @ncs1!
15
+
16
+
17
+ ## 2.8.2 / 2021-08-06
18
+
19
+ ### Dependencies
20
+
21
+ * Update dependency on Addressable from `~>2.7` to `~>2.8`. (#584) @yidingww
22
+
23
+
24
+ ## 2.8.1 / 2021-05-09
25
+
26
+ ### Fix
27
+
28
+ * Gracefully handle parsing errors that contain an invalid byte sequence. Previously, if libxml2 registered a parsing error that itself contained invalid encoding, an exception might be raised. (#553)
29
+
30
+
3
31
  ## 2.8.0 / 2021-04-01
4
32
 
5
- * Requirements
6
- * Mechanize now requires Ruby 2.5 or newer.
7
- * Move from `ntlm-http` to `rubyntlm` gem. (#495, #574)
33
+ ### Requirements
8
34
 
9
- * New Features
10
- * Page::Link#uri now handles non-ASCII `href`s. (#569) @terryyin
11
- * FileConnection supports Windows drive letters (#483)
12
- * Credential headers 'Authorization' and 'Cookie' are deleted on cross-origin redirects. (#538) @kyoshidajp
13
- * ContentDispositionParser handles ISO8601 date headers, to be robust with websites that ignore RFC2183. (#554) @reitermarkus
35
+ * Mechanize now requires Ruby 2.5 or newer.
36
+ * Move from `ntlm-http` to `rubyntlm` gem. (#495, #574)
37
+
38
+ ### New Features
39
+
40
+ * Page::Link#uri now handles non-ASCII `href`s. (#569) @terryyin
41
+ * FileConnection supports Windows drive letters (#483)
42
+ * Credential headers 'Authorization' and 'Cookie' are deleted on cross-origin redirects. (#538) @kyoshidajp
43
+ * ContentDispositionParser handles ISO8601 date headers, to be robust with websites that ignore RFC2183. (#554) @reitermarkus
44
+
45
+ ### Bug fix
46
+
47
+ * POST headers 'Content-Length', 'Content-MD5', and 'Content-Type' are deleted in a case-insensitive manner on redirects. Previously these headers were treated as case-sensitive.
14
48
 
15
- * Bug fix
16
- * POST headers 'Content-Length', 'Content-MD5', and 'Content-Type' are deleted in a case-insensitive manner on redirects. Previously these headers were treated as case-sensitive.
17
49
 
18
50
  ## 2.7.7 / 2021-02-01
19
51
 
@@ -117,8 +149,7 @@
117
149
  * Mechanize::Agent#response_read will now raise a
118
150
  Mechanize::ResponseReadError instead of an EOFError and avoid losing
119
151
  requested content. #296.
120
- * Depend on http-cookie, add backwards compatible deprecations.
121
- #257 Akinori MUSHA.
152
+ * Depend on http-cookie, add backwards compatible deprecations. #257 Akinori MUSHA.
122
153
  * Added `Download#save!` for overwriting existing files. #300 Sean Kim.
123
154
 
124
155
  * Bug fix
@@ -147,13 +178,10 @@
147
178
  * Added iPad and Android user agents. #277 by sambit, #278 by seansay.
148
179
 
149
180
  * Bug fix
150
- * Mechanize#cert and Mechanize#key now return the values set by
151
- #cert= and #key=. #244, #245 (Thanks, Robert Gogolok!)
152
- * Mechanize no longer submits disabled form fields. #276 by Bogdan Gusiev,
153
- #279 by Ricardo Valeriano.
181
+ * Mechanize#cert and Mechanize#key now return the values set by #cert= and #key=. #244, #245 (Thanks, Robert Gogolok!)
182
+ * Mechanize no longer submits disabled form fields. #276 by Bogdan Gusiev, #279 by Ricardo Valeriano.
154
183
  * Mechanize::File#save now behaves like Mechanize::Download#save in
155
- that it will create the parent directory before saving.
156
- #272, #280 by Ryan Kowalick
184
+ that it will create the parent directory before saving. #272, #280 by Ryan Kowalick
157
185
  * Ensure `application/xml` is registered as an XML parser in
158
186
  `PluggableParser`, not just `text/xml`. #266 James Gregory
159
187
  * Mechanize now writes cookiestxt with a prefixed dot for wildcard domain
@@ -173,8 +201,7 @@
173
201
  In mechanize 3 the old "Mac FireFox" user-agent alias will be removed.
174
202
  Pull request #231 by Gavin Miller.
175
203
  * Mechanize now authenticates using the raw challenge, not a reconstructed
176
- one, to avoid dealing with quoting rules of RFC 2617. Fixes failures in
177
- #231 due to net-http-digest_auth 1.2.1
204
+ one, to avoid dealing with quoting rules of RFC 2617. Fixes failures in #231 due to net-http-digest_auth 1.2.1
178
205
  * Fixed Content-Disposition parameter parser to be case insensitive. #233
179
206
  * Fixed redirection counting in following meta refresh. #240
180
207
 
@@ -205,8 +232,7 @@
205
232
  terminate chunked transfer-encoding properly. Issue #116
206
233
  * Mechanize no longer raises an exception when multiple identical
207
234
  radiobuttons are checked. Issue #214 by Matthias Guenther
208
- * Fixed documentation for pre_connect_hooks and post_connect_hooks. Issue
209
- #226 by Robert Poor
235
+ * Fixed documentation for pre_connect_hooks and post_connect_hooks. Issue #226 by Robert Poor
210
236
  * Worked around ruby 1.8 run with -Ku and ISO-8859-1 encoded characters in
211
237
  URIs. Issue #228 by Stanislav O.Pogrebnyak
212
238
 
@@ -272,8 +298,7 @@
272
298
  * SSL parameters and proxy may now be set at any time. Issue #194 by
273
299
  dsisnero.
274
300
  * Improved Mechanize::Page with #image_with and #images_with and
275
- Mechanize::Page::Image various img element attribute accessors, #caption,
276
- #extname, #mime_type and #fetch. Pull request #173 by kitamomonga
301
+ Mechanize::Page::Image various img element attribute accessors, #caption, #extname, #mime_type and #fetch. Pull request #173 by kitamomonga
277
302
  * Added MIME type parsing for content-types in Mechanize::PluggableParser
278
303
  for fine-grained parser choices. Parsers will be chosen based on exact
279
304
  match, simplified type or media type in that order. See
@@ -336,8 +361,7 @@
336
361
  * SSL connections will be verified against the system certificate store by
337
362
  default.
338
363
  * Added Mechanize#retry_change_requests to allow mechanize to retry POST and
339
- other non-idempotent requests when you know it is safe to do so. Issue
340
- #123
364
+ other non-idempotent requests when you know it is safe to do so. Issue #123
341
365
  * Mechanize can now stream files directly to disk without loading them into
342
366
  memory first through Mechanize::Download, a pluggable parser for
343
367
  downloading files.
@@ -352,8 +376,7 @@
352
376
  agent.pluggable_parser.default = Mechanize::Download
353
377
  * Added Mechanize#content_encoding_hooks which allow handling of
354
378
  non-standard content encodings like "agzip". Patch #125 by kitamomonga
355
- * Added dom_class to elements and the element matcher like dom_id. Patch
356
- #156 by Dan Hansen.
379
+ * Added dom_class to elements and the element matcher like dom_id. Patch #156 by Dan Hansen.
357
380
  * Added support for the HTML5 keygen form element. See
358
381
  http://dev.w3.org/html5/spec/Overview.html#the-keygen-element Patch #157
359
382
  by Victor Costan.
@@ -402,8 +425,7 @@
402
425
  * The original Referer value persists on redirection. Issue #150
403
426
  * Do not send a referer on a Refresh header based redirection.
404
427
  * Fixed encoding error in tests when LANG=C. Patch #142 by jinschoi.
405
- * The order of items in a form submission now match the DOM order. Patch
406
- #129 by kitamomonga
428
+ * The order of items in a form submission now match the DOM order. Patch #129 by kitamomonga
407
429
  * Fixed proxy example in EXAMPLE. Issue #146 by NielsKSchjoedt
408
430
 
409
431
  ## 2.0.1 / 2011-06-28
@@ -471,8 +493,7 @@ Mechanize is now under the MIT license
471
493
  * Mechanize now implements session cookies. GH #78
472
494
  * Mechanize now implements deflate decoding. GH #40
473
495
  * Mechanize now allows a certificate and key to be passed directly. GH #71
474
- * Mechanize::Form::MultiSelectList now implements #option_with and
475
- #options_with. GH #42
496
+ * Mechanize::Form::MultiSelectList now implements #option_with and #options_with. GH #42
476
497
  * Add Mechanize::Page::Link#rel and #rel?(kind) to read and test the rel
477
498
  attribute.
478
499
  * Add Mechanize::Page#canonical_uri to read a </tt><link
data/README.md CHANGED
@@ -74,6 +74,4 @@ Thank you to Michael Neumann for starting the Ruby version. Thanks to everyone w
74
74
 
75
75
  ## License
76
76
 
77
- This library is distributed under the MIT license. Please see the [LICENSE](http://docs.seattlerb.org/mechanize/LICENSE_rdoc.html) file.
78
-
79
-
77
+ This library is distributed under the MIT license. Please see [LICENSE.txt](https://github.com/sparklemotion/mechanize/blob/main/LICENSE.txt).
@@ -149,7 +149,7 @@ class Mechanize
149
149
  return super(input, opthash) if opthash[:format] != :yaml
150
150
 
151
151
  begin
152
- data = YAML.load(input) # rubocop:disable Security/YAMLLoad
152
+ data = load_yaml(input)
153
153
  rescue ArgumentError
154
154
  @logger.warn "unloadable YAML cookie data discarded" if @logger
155
155
  return self
@@ -174,6 +174,18 @@ class Mechanize
174
174
  return self
175
175
  end
176
176
  end
177
+
178
+ private
179
+
180
+ if YAML.name == "Psych" && Gem::Requirement.new(">= 3.1").satisfied_by?(Gem::Version.new(Psych::VERSION))
181
+ def load_yaml(yaml)
182
+ YAML.safe_load(yaml, aliases: true, permitted_classes: ["Mechanize::Cookie", "Time"])
183
+ end
184
+ else
185
+ def load_yaml(yaml)
186
+ YAML.load(yaml) # rubocop:disable Security/YAMLLoad
187
+ end
188
+ end
177
189
  end
178
190
 
179
191
  class ::HTTP::CookieJar
@@ -104,9 +104,9 @@ class Mechanize::Page < Mechanize::File
104
104
  parser = self.parser unless parser
105
105
  return false if parser.errors.empty?
106
106
  parser.errors.any? do |error|
107
- error.message =~ /(indicate\ encoding)|
108
- (Invalid\ char)|
109
- (input\ conversion\ failed)/x
107
+ error.message.scrub =~ /(indicate\ encoding)|
108
+ (Invalid\ char)|
109
+ (input\ conversion\ failed)/x
110
110
  end
111
111
  end
112
112
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Mechanize
3
- VERSION = "2.8.0"
3
+ VERSION = "2.8.4"
4
4
  end
data/lib/mechanize.rb CHANGED
@@ -115,7 +115,7 @@ class Mechanize
115
115
 
116
116
  AGENT_ALIASES = {
117
117
  'Mechanize' => "Mechanize/#{VERSION} Ruby/#{ruby_version} (http://github.com/sparklemotion/mechanize/)",
118
- 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0',
118
+ 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0',
119
119
  'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
120
120
  'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
121
121
  'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0',
data/mechanize.gemspec CHANGED
@@ -1,13 +1,11 @@
1
1
  # coding: utf-8
2
2
  # frozen_string_literal: true
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'mechanize/version'
3
+ require_relative 'lib/mechanize/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = "mechanize"
9
7
  spec.version = Mechanize::VERSION
10
- spec.homepage = "http://docs.seattlerb.org/mechanize/"
8
+ spec.homepage = "https://github.com/sparklemotion/mechanize"
11
9
  spec.summary = 'The Mechanize library is used for automating interaction with websites'
12
10
  spec.description =
13
11
  [
@@ -35,6 +33,15 @@ Gem::Specification.new do |spec|
35
33
  'ljjarvis@gmail.com',
36
34
  ]
37
35
 
36
+ spec.metadata = {
37
+ 'yard.run' => 'yard',
38
+ 'bug_tracker_uri' => 'https://github.com/sparklemotion/mechanize/issues',
39
+ 'changelog_uri' => 'https://github.com/sparklemotion/mechanize/blob/main/CHANGELOG.md',
40
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/mechanize',
41
+ 'homepage_uri' => 'https://github.com/sparklemotion/mechanize',
42
+ 'source_code_uri' => 'https://github.com/sparklemotion/mechanize'
43
+ }
44
+
38
45
  spec.license = "MIT"
39
46
 
40
47
  spec.require_paths = ["lib"]
@@ -46,7 +53,7 @@ Gem::Specification.new do |spec|
46
53
 
47
54
  spec.required_ruby_version = ">= 2.5.0"
48
55
 
49
- spec.add_runtime_dependency("addressable", "~> 2.7")
56
+ spec.add_runtime_dependency("addressable", "~> 2.8")
50
57
  spec.add_runtime_dependency("domain_name", ">= 0.5.20190701", "~> 0.5")
51
58
  spec.add_runtime_dependency("http-cookie", ">= 1.0.3", "~> 1.0")
52
59
  spec.add_runtime_dependency("mime-types", "~> 3.0")
@@ -183,5 +183,32 @@ class TestMechanizePageEncoding < Mechanize::TestCase
183
183
  assert_equal Encoding::UTF_8, result.text.encoding
184
184
  end
185
185
 
186
- end
186
+ def test_parser_error_message_containing_encoding_errors
187
+ skip if RUBY_ENGINE == 'jruby' # this is a libxml2-specific condition
188
+
189
+ # https://github.com/sparklemotion/mechanize/issues/553
190
+ body = <<~EOF
191
+ <html>
192
+ <body>
193
+ <!--
194
+ ## メモ
195
+ 処理の一般化, 二重ループ, 多重ループ
196
+ wzxhzdk:25
197
+ -->
198
+ EOF
199
+ page = util_page body
200
+
201
+ # this should not raise an "invalid byte sequence in UTF-8" error while processing parsing errors
202
+ page.search("body")
187
203
 
204
+ # let's assert on the setup: a libxml2-returned parsing error itself contains an invalid character
205
+ # note that this problem only appears in libxml <= 2.9.10
206
+ error = page.parser.errors.find { |e| e.message.include?("Comment not terminated") }
207
+ if error
208
+ exception = assert_raises(ArgumentError) do
209
+ error.message =~ /any regex just to trigger encoding error/
210
+ end
211
+ assert_includes(exception.message, "invalid byte sequence in UTF-8")
212
+ end
213
+ end
214
+ end
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.8.0
4
+ version: 2.8.4
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: 2021-04-01 00:00:00.000000000 Z
15
+ date: 2022-01-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '2.7'
23
+ version: '2.8'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '2.7'
30
+ version: '2.8'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: domain_name
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -261,12 +261,13 @@ email:
261
261
  executables: []
262
262
  extensions: []
263
263
  extra_rdoc_files:
264
- - GUIDE.rdoc
265
264
  - EXAMPLES.rdoc
266
- - README.md
265
+ - GUIDE.rdoc
267
266
  - CHANGELOG.md
267
+ - README.md
268
268
  files:
269
269
  - ".autotest"
270
+ - ".github/dependabot.yml"
270
271
  - ".github/workflows/ci-test.yml"
271
272
  - ".gitignore"
272
273
  - ".yardopts"
@@ -474,10 +475,16 @@ files:
474
475
  - test/test_mechanize_util.rb
475
476
  - test/test_mechanize_xml_file.rb
476
477
  - test/test_multi_select.rb
477
- homepage: http://docs.seattlerb.org/mechanize/
478
+ homepage: https://github.com/sparklemotion/mechanize
478
479
  licenses:
479
480
  - MIT
480
- metadata: {}
481
+ metadata:
482
+ yard.run: yard
483
+ bug_tracker_uri: https://github.com/sparklemotion/mechanize/issues
484
+ changelog_uri: https://github.com/sparklemotion/mechanize/blob/main/CHANGELOG.md
485
+ documentation_uri: https://www.rubydoc.info/gems/mechanize
486
+ homepage_uri: https://github.com/sparklemotion/mechanize
487
+ source_code_uri: https://github.com/sparklemotion/mechanize
481
488
  post_install_message:
482
489
  rdoc_options:
483
490
  - "--main"
@@ -495,7 +502,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
495
502
  - !ruby/object:Gem::Version
496
503
  version: '0'
497
504
  requirements: []
498
- rubygems_version: 3.1.4
505
+ rubygems_version: 3.3.5
499
506
  signing_key:
500
507
  specification_version: 4
501
508
  summary: The Mechanize library is used for automating interaction with websites