mechanize 2.7.1 → 2.7.2

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
  SHA1:
3
- metadata.gz: a97a6fd7fb8b0c358b45a7f457fb0e6fa3878e41
4
- data.tar.gz: 4476cd31d79931fe29635bdd34491b2b90ae1663
3
+ metadata.gz: 540e567d390aebe104b22b2c11c726c9bceef098
4
+ data.tar.gz: c86f1051ac42694d9390856a53724a1b76019a35
5
5
  SHA512:
6
- metadata.gz: cb4c0755690791b5747e2ff4b44bd063088ee7481cced3ae15a4f7dbe19f70ed74837a5c0e90bb4da387be85012169455374dd00b5b3f0464134aad7ff3aa08d
7
- data.tar.gz: de0b415c13d960df9bc6fb732a7eecd85b188e081b0123e61edfec37c868ef6a029a69f8dc394c4aa679d9becf29e3c0a50d557b3ba0a08e5d7c7407dfb54dd8
6
+ metadata.gz: 949355d69adf7c58dfa355508e25044535f2880f7a7640d29ee8177d354850fb972dc625c4fac32c7b7e7496d5ca9eae94ad3fb47fc4ee37a45ad9d19f3a10d7
7
+ data.tar.gz: c0a04825b124542b1d5eee4749402bfe64de7ba49b52952054f1fe92cd2d6607628174e76d8d2ca3f8be90b0da46871cb26db55be0fc3bf388ff0c266daf82f7
@@ -11,7 +11,6 @@ notifications:
11
11
  - ljjarvis@gmail.com
12
12
  - knu@idaemons.org
13
13
  rvm:
14
- - 1.9.2
15
14
  - 1.9.3
16
15
  - 2.0.0
17
16
  - ruby-head
@@ -1,9 +1,17 @@
1
1
  = Mechanize CHANGELOG
2
2
 
3
+ === 2.7.2
4
+
5
+ * Bug fix
6
+ * API compatibility issues with Mechanize::CookieJar cookies has been
7
+ addressed. https://github.com/sparklemotion/http-cookie/issues/2 #326
8
+
3
9
  === 2.7.1
4
10
 
5
11
  * Bug fix
6
12
  * Ensure images with no "src" attribute still return correct URLs. #317
13
+ * Fixes Mechanize::Parser#extract_filename where an empty string filename
14
+ in the response caused unhandled exception. #318
7
15
 
8
16
  === 2.7.0
9
17
 
@@ -73,7 +73,7 @@ class Mechanize
73
73
  ##
74
74
  # The version of Mechanize you are using.
75
75
 
76
- VERSION = '2.7.1'
76
+ VERSION = '2.7.2'
77
77
 
78
78
  ##
79
79
  # Base mechanize error class
@@ -123,6 +123,7 @@ class Mechanize
123
123
  'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
124
124
  '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',
125
125
  'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22',
126
+ 'Windows Chrome' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.32 Safari/537.36',
126
127
  'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
127
128
  '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
129
  '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)',
@@ -48,10 +48,25 @@ class Mechanize
48
48
  __deprecated__ :store
49
49
  @store.instance_variable_get(:@jar)
50
50
  end
51
+
52
+ # See HTTP::CookieJar#load.
53
+ def load_cookiestxt(io)
54
+ __deprecated__ :load
55
+ load(io, :cookiestxt)
56
+ end
57
+
58
+ # See HTTP::CookieJar#save.
59
+ def dump_cookiestxt(io)
60
+ __deprecated__ :save
61
+ save(io, :cookiestxt)
62
+ end
51
63
  end
52
64
 
53
65
  class CookieJar < ::HTTP::CookieJar
54
- def save(filename, *options)
66
+ def save(output, *options)
67
+ output.respond_to?(:write) or
68
+ return open(output, 'w') { |io| save(io, *options) }
69
+
55
70
  opthash = {
56
71
  :format => :yaml,
57
72
  :session => false,
@@ -72,7 +87,7 @@ class Mechanize
72
87
  raise ArgumentError, 'wrong number of arguments (%d for 1-3)' % (1 + options.size)
73
88
  end
74
89
 
75
- return super if opthash[:format] != :yaml
90
+ return super(output, opthash) if opthash[:format] != :yaml
76
91
 
77
92
  session = opthash[:session]
78
93
  nstore = HashStore.new
@@ -97,43 +112,66 @@ class Mechanize
97
112
  $1 + ($2 ? Time.parse($2).httpdate : '')
98
113
  }
99
114
 
100
- open(filename, 'w') { |io|
101
- io.write yaml
102
- }
115
+ output.write yaml
103
116
 
104
117
  self
105
118
  end
106
119
 
107
- def load(filename, format = :yaml)
108
- return super if format != :yaml
120
+ def load(input, *options)
121
+ input.respond_to?(:write) or
122
+ return open(input, 'r') { |io| load(io, *options) }
109
123
 
110
- open(filename) { |io|
111
- begin
112
- data = YAML.load(io)
113
- rescue ArgumentError
114
- @logger.warn "unloadable YAML cookie data discarded" if @logger
115
- return
124
+ opthash = {
125
+ :format => :yaml,
126
+ :session => false,
127
+ }
128
+ case options.size
129
+ when 0
130
+ when 1
131
+ case options = options.first
132
+ when Symbol
133
+ opthash[:format] = options
134
+ else
135
+ if hash = Hash.try_convert(options)
136
+ opthash.update(hash)
137
+ end
116
138
  end
139
+ when 2
140
+ opthash[:format], options = options
141
+ if hash = Hash.try_convert(options)
142
+ opthash.update(hash)
143
+ end
144
+ else
145
+ raise ArgumentError, 'wrong number of arguments (%d for 1-3)' % (1 + options.size)
146
+ end
117
147
 
118
- case data
119
- when Array
120
- # Forward compatibility
121
- data.each { |cookie|
122
- add(cookie)
123
- }
124
- when Hash
125
- data.each { |domain, paths|
126
- paths.each { |path, names|
127
- names.each { |cookie_name, cookie|
128
- add(cookie)
129
- }
148
+ return super(input, opthash) if opthash[:format] != :yaml
149
+
150
+ begin
151
+ data = YAML.load(input)
152
+ rescue ArgumentError
153
+ @logger.warn "unloadable YAML cookie data discarded" if @logger
154
+ return self
155
+ end
156
+
157
+ case data
158
+ when Array
159
+ # Forward compatibility
160
+ data.each { |cookie|
161
+ add(cookie)
162
+ }
163
+ when Hash
164
+ data.each { |domain, paths|
165
+ paths.each { |path, names|
166
+ names.each { |cookie_name, cookie|
167
+ add(cookie)
130
168
  }
131
169
  }
132
- else
133
- @logger.warn "incompatible YAML cookie data discarded" if @logger
134
- return
135
- end
136
- }
170
+ }
171
+ else
172
+ @logger.warn "incompatible YAML cookie data discarded" if @logger
173
+ return self
174
+ end
137
175
  end
138
176
  end
139
177
 
@@ -7,6 +7,13 @@ class Mechanize::Form::CheckBox < Mechanize::Form::RadioButton
7
7
  def query_value
8
8
  [[@name, @value || "on"]]
9
9
  end
10
+
11
+ def inspect # :nodoc:
12
+ "[%s:0x%x type: %s name: %s value: %s]" % [
13
+ self.class.name.sub(/Mechanize::Form::/, '').downcase,
14
+ object_id, type, name, checked
15
+ ]
16
+ end
10
17
 
11
18
  end
12
19
 
@@ -122,7 +122,7 @@ module Mechanize::Parser
122
122
  content_disposition =
123
123
  Mechanize::HTTP::ContentDispositionParser.parse disposition
124
124
 
125
- if content_disposition && content_disposition.filename then
125
+ if content_disposition && content_disposition.filename && content_disposition.filename != '' then
126
126
  filename = content_disposition.filename
127
127
  filename = filename.split(/[\\\/]/).last
128
128
  handled = true
@@ -336,11 +336,23 @@ class TestMechanizeCookieJar < Mechanize::TestCase
336
336
  in_tmpdir do
337
337
  @jar.save_as("cookies.txt", :cookiestxt)
338
338
 
339
+ assert_match(/\A# (?:Netscape )?HTTP Cookie File$/, File.read("cookies.txt"))
340
+
339
341
  jar = Mechanize::CookieJar.new
340
- jar.load("cookies.txt", :cookiestxt) # HACK test the format
342
+ jar.load("cookies.txt", :cookiestxt)
341
343
  assert_equal(2, jar.cookies(url).length)
342
344
  end
343
345
 
346
+ in_tmpdir do
347
+ @jar.save_as("cookies.txt", :cookiestxt, :session => true)
348
+
349
+ assert_match(/\A# (?:Netscape )?HTTP Cookie File$/, File.read("cookies.txt"))
350
+
351
+ jar = Mechanize::CookieJar.new
352
+ jar.load("cookies.txt", :cookiestxt)
353
+ assert_equal(3, jar.cookies(url).length)
354
+ end
355
+
344
356
  assert_equal(3, @jar.cookies(url).length)
345
357
  end
346
358
 
@@ -45,6 +45,12 @@ class TestMechanizeParser < Mechanize::TestCase
45
45
  }
46
46
 
47
47
  assert_equal 'foo.html', @parser.extract_filename
48
+
49
+ @parser.response = {
50
+ 'content-disposition' => "inline; filename=\"\""
51
+ }
52
+
53
+ assert_equal 'foo.html', @parser.extract_filename
48
54
  end
49
55
 
50
56
  def test_extract_filename_content_disposition_path
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.7.1
4
+ version: 2.7.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: 2013-05-27 00:00:00.000000000 Z
15
+ date: 2013-08-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: net-http-digest_auth
@@ -196,14 +196,14 @@ dependencies:
196
196
  requirements:
197
197
  - - ~>
198
198
  - !ruby/object:Gem::Version
199
- version: '3.6'
199
+ version: '3.7'
200
200
  type: :development
201
201
  prerelease: false
202
202
  version_requirements: !ruby/object:Gem::Requirement
203
203
  requirements:
204
204
  - - ~>
205
205
  - !ruby/object:Gem::Version
206
- version: '3.6'
206
+ version: '3.7'
207
207
  description: |-
208
208
  The Mechanize library is used for automating interaction with websites.
209
209
  Mechanize automatically stores and sends cookies, follows redirects,
@@ -431,7 +431,8 @@ files:
431
431
  - test/test_multi_select.rb
432
432
  - .gemtest
433
433
  homepage: http://mechanize.rubyforge.org
434
- licenses: []
434
+ licenses:
435
+ - MIT
435
436
  metadata: {}
436
437
  post_install_message:
437
438
  rdoc_options:
@@ -451,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
451
452
  version: '0'
452
453
  requirements: []
453
454
  rubyforge_project: mechanize
454
- rubygems_version: 2.0.3
455
+ rubygems_version: 2.0.2
455
456
  signing_key:
456
457
  specification_version: 4
457
458
  summary: The Mechanize library is used for automating interaction with websites