rubygems-update 3.2.34 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -4
  3. data/CONTRIBUTING.md +40 -10
  4. data/Manifest.txt +6 -5
  5. data/POLICIES.md +22 -8
  6. data/README.md +9 -7
  7. data/UPGRADING.md +5 -81
  8. data/bin/gem +1 -6
  9. data/bundler/CHANGELOG.md +27 -0
  10. data/bundler/exe/bundle +7 -8
  11. data/bundler/lib/bundler/build_metadata.rb +2 -2
  12. data/bundler/lib/bundler/cli/gem.rb +1 -1
  13. data/bundler/lib/bundler/cli/install.rb +2 -0
  14. data/bundler/lib/bundler/cli.rb +5 -0
  15. data/bundler/lib/bundler/definition.rb +14 -2
  16. data/bundler/lib/bundler/dependency.rb +5 -7
  17. data/bundler/lib/bundler/dsl.rb +0 -27
  18. data/bundler/lib/bundler/endpoint_specification.rb +0 -8
  19. data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
  20. data/bundler/lib/bundler/fetcher.rb +2 -5
  21. data/bundler/lib/bundler/injector.rb +10 -1
  22. data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
  23. data/bundler/lib/bundler/installer.rb +1 -4
  24. data/bundler/lib/bundler/lockfile_parser.rb +10 -13
  25. data/bundler/lib/bundler/man/bundle-add.1 +9 -1
  26. data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
  27. data/bundler/lib/bundler/man/bundle-config.1 +2 -2
  28. data/bundler/lib/bundler/man/bundle-config.1.ronn +3 -3
  29. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
  31. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
  33. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  34. data/bundler/lib/bundler/man/gemfile.5.ronn +1 -1
  35. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  36. data/bundler/lib/bundler/process_lock.rb +1 -1
  37. data/bundler/lib/bundler/psyched_yaml.rb +1 -13
  38. data/bundler/lib/bundler/resolver.rb +34 -29
  39. data/bundler/lib/bundler/rubygems_ext.rb +2 -0
  40. data/bundler/lib/bundler/rubygems_integration.rb +11 -48
  41. data/bundler/lib/bundler/self_manager.rb +73 -0
  42. data/bundler/lib/bundler/shared_helpers.rb +2 -9
  43. data/bundler/lib/bundler/source/metadata.rb +1 -1
  44. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  45. data/bundler/lib/bundler/templates/Gemfile +0 -2
  46. data/bundler/lib/bundler/templates/gems.rb +0 -3
  47. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +10 -1
  48. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  49. data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  50. data/bundler/lib/bundler/ui/shell.rb +1 -1
  51. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  52. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +2 -1
  53. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +2 -6
  54. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -6
  55. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +4 -9
  56. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -19
  57. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +4 -22
  58. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  59. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  60. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  61. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  62. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  63. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  64. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  65. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  66. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  67. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  68. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  69. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  70. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  71. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  72. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  73. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  74. data/bundler/lib/bundler/version.rb +1 -1
  75. data/bundler/lib/bundler.rb +9 -3
  76. data/hide_lib_for_update/note.txt +0 -4
  77. data/lib/rubygems/command_manager.rb +1 -1
  78. data/lib/rubygems/commands/install_command.rb +5 -2
  79. data/lib/rubygems/commands/server_command.rb +14 -77
  80. data/lib/rubygems/commands/setup_command.rb +4 -16
  81. data/lib/rubygems/commands/update_command.rb +9 -4
  82. data/lib/rubygems/defaults.rb +2 -20
  83. data/lib/rubygems/deprecate.rb +55 -8
  84. data/lib/rubygems/exceptions.rb +26 -1
  85. data/lib/rubygems/ext/builder.rb +5 -3
  86. data/lib/rubygems/install_update_options.rb +11 -2
  87. data/lib/rubygems/installer.rb +11 -1
  88. data/lib/rubygems/name_tuple.rb +2 -3
  89. data/lib/rubygems/path_support.rb +1 -6
  90. data/lib/rubygems/platform.rb +4 -0
  91. data/lib/rubygems/remote_fetcher.rb +1 -1
  92. data/lib/rubygems/resolver/installer_set.rb +1 -1
  93. data/lib/rubygems/security.rb +4 -3
  94. data/lib/rubygems/source.rb +3 -1
  95. data/lib/rubygems/spec_fetcher.rb +1 -1
  96. data/lib/rubygems/specification.rb +9 -13
  97. data/lib/rubygems/text.rb +21 -20
  98. data/lib/rubygems/uninstaller.rb +4 -1
  99. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  100. data/lib/rubygems/version.rb +2 -0
  101. data/lib/rubygems.rb +3 -3
  102. data/rubygems-update.gemspec +1 -1
  103. data/setup.rb +1 -6
  104. data/test/rubygems/helper.rb +20 -6
  105. data/test/rubygems/test_config.rb +2 -2
  106. data/test/rubygems/test_exit.rb +11 -0
  107. data/test/rubygems/test_gem.rb +46 -41
  108. data/test/rubygems/test_gem_command_manager.rb +16 -27
  109. data/test/rubygems/test_gem_commands_open_command.rb +1 -1
  110. data/test/rubygems/test_gem_commands_server_command.rb +4 -46
  111. data/test/rubygems/test_gem_commands_update_command.rb +2 -2
  112. data/test/rubygems/test_gem_path_support.rb +2 -6
  113. data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
  114. data/test/rubygems/test_gem_requirement.rb +0 -1
  115. data/test/rubygems/test_gem_security.rb +1 -1
  116. data/test/rubygems/test_gem_source_git.rb +0 -5
  117. data/test/rubygems/test_gem_specification.rb +16 -25
  118. data/test/rubygems/test_gem_text.rb +6 -0
  119. data/test/rubygems/test_project_sanity.rb +1 -1
  120. data/test/rubygems/test_require.rb +0 -7
  121. metadata +9 -8
  122. data/bundler/lib/bundler/gemdeps.rb +0 -29
  123. data/lib/rubygems/server.rb +0 -882
  124. data/test/rubygems/bogussources.rb +0 -9
  125. data/test/rubygems/test_gem_server.rb +0 -608
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
- require 'rubygems'
9
- Gem.use_paths("test/mock/gems")
@@ -1,608 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'helper'
3
- require 'rubygems/server'
4
- require 'stringio'
5
-
6
- class Gem::Server
7
- attr_reader :server
8
- end
9
-
10
- class TestGemServer < Gem::TestCase
11
- def process_based_port
12
- 0
13
- end
14
-
15
- def setup
16
- super
17
-
18
- @a1 = quick_gem 'a', '1'
19
- @a2 = quick_gem 'a', '2'
20
- @a3_p = quick_gem 'a', '3.a'
21
-
22
- @server = Gem::Server.new Gem.dir, process_based_port, false
23
- @req = WEBrick::HTTPRequest.new :Logger => nil
24
- @res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
25
- end
26
-
27
- def test_doc_root_3
28
- orig_rdoc_version = Gem::RDoc.rdoc_version
29
- Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('3.12')
30
-
31
- assert_equal '/doc_root/X-1/rdoc/index.html', @server.doc_root('X-1')
32
-
33
- ensure
34
- Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
35
- end
36
-
37
- def test_doc_root_4
38
- orig_rdoc_version = Gem::RDoc.rdoc_version
39
- Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('4.0')
40
-
41
- assert_equal '/doc_root/X-1/', @server.doc_root('X-1')
42
-
43
- ensure
44
- Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
45
- end
46
-
47
- def test_have_rdoc_4_plus_eh
48
- orig_rdoc_version = Gem::RDoc.rdoc_version
49
- Gem::RDoc.instance_variable_set(:@rdoc_version, Gem::Version.new('4.0'))
50
-
51
- server = Gem::Server.new Gem.dir, 0, false
52
- assert server.have_rdoc_4_plus?
53
-
54
- Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('3.12')
55
-
56
- server = Gem::Server.new Gem.dir, 0, false
57
- refute server.have_rdoc_4_plus?
58
-
59
- Gem::RDoc.instance_variable_set(:@rdoc_version,
60
- Gem::Version.new('4.0.0.preview2'))
61
-
62
- server = Gem::Server.new Gem.dir, 0, false
63
- assert server.have_rdoc_4_plus?
64
- ensure
65
- Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
66
- end
67
-
68
- def test_spec_dirs
69
- s = Gem::Server.new Gem.dir, process_based_port, false
70
-
71
- assert_equal [File.join(Gem.dir, 'specifications')], s.spec_dirs
72
-
73
- s = Gem::Server.new [Gem.dir, Gem.dir], process_based_port, false
74
-
75
- assert_equal [File.join(Gem.dir, 'specifications'),
76
- File.join(Gem.dir, 'specifications')], s.spec_dirs
77
- end
78
-
79
- def test_latest_specs
80
- data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
81
- @req.parse data
82
-
83
- Gem::Deprecate.skip_during do
84
- @server.latest_specs @req, @res
85
- end
86
-
87
- assert_equal 200, @res.status, @res.body
88
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
89
- assert_equal 'application/octet-stream', @res['content-type']
90
- assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
91
- Marshal.load(@res.body)
92
- end
93
-
94
- def test_latest_specs_gemdirs
95
- data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
96
- dir = "#{@gemhome}2"
97
-
98
- spec = util_spec 'z', 9
99
-
100
- specs_dir = File.join dir, 'specifications'
101
- FileUtils.mkdir_p specs_dir
102
-
103
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
104
- io.write spec.to_ruby
105
- end
106
-
107
- server = Gem::Server.new dir, process_based_port, false
108
-
109
- @req.parse data
110
-
111
- server.latest_specs @req, @res
112
-
113
- assert_equal 200, @res.status
114
-
115
- assert_equal [['z', v(9), Gem::Platform::RUBY]], Marshal.load(@res.body)
116
- end
117
-
118
- def test_latest_specs_gz
119
- data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
120
- @req.parse data
121
-
122
- Gem::Deprecate.skip_during do
123
- @server.latest_specs @req, @res
124
- end
125
-
126
- assert_equal 200, @res.status, @res.body
127
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
128
- assert_equal 'application/x-gzip', @res['content-type']
129
- assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
130
- Marshal.load(Gem::Util.gunzip(@res.body))
131
- end
132
-
133
- def test_listen
134
- util_listen
135
-
136
- capture_output do
137
- @server.listen
138
- end
139
-
140
- assert_equal 1, @server.server.listeners.length
141
- end
142
-
143
- def test_listen_addresses
144
- util_listen
145
-
146
- capture_output do
147
- @server.listen %w[a b]
148
- end
149
-
150
- assert_equal 2, @server.server.listeners.length
151
- end
152
-
153
- def test_prerelease_specs
154
- data = StringIO.new "GET /prerelease_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
155
- @req.parse data
156
-
157
- Gem::Deprecate.skip_during do
158
- @server.prerelease_specs @req, @res
159
- end
160
-
161
- assert_equal 200, @res.status, @res.body
162
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
163
- assert_equal 'application/octet-stream', @res['content-type']
164
- assert_equal [['a', v('3.a'), Gem::Platform::RUBY]],
165
- Marshal.load(@res.body)
166
- end
167
-
168
- def test_prerelease_specs_gz
169
- data = StringIO.new "GET /prerelease_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
170
- @req.parse data
171
-
172
- Gem::Deprecate.skip_during do
173
- @server.prerelease_specs @req, @res
174
- end
175
-
176
- assert_equal 200, @res.status, @res.body
177
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
178
- assert_equal 'application/x-gzip', @res['content-type']
179
- assert_equal [['a', v('3.a'), Gem::Platform::RUBY]],
180
- Marshal.load(Gem::Util.gunzip(@res.body))
181
- end
182
-
183
- def test_quick_gemdirs
184
- data = StringIO.new "GET /quick/Marshal.4.8/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
185
- dir = "#{@gemhome}2"
186
-
187
- server = Gem::Server.new dir, process_based_port, false
188
-
189
- @req.parse data
190
-
191
- server.quick @req, @res
192
-
193
- assert_equal 404, @res.status
194
-
195
- spec = util_spec 'z', 9
196
-
197
- specs_dir = File.join dir, 'specifications'
198
-
199
- FileUtils.mkdir_p specs_dir
200
-
201
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
202
- io.write spec.to_ruby
203
- end
204
-
205
- data.rewind
206
-
207
- req = WEBrick::HTTPRequest.new :Logger => nil
208
- res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
209
- req.parse data
210
-
211
- server.quick req, res
212
-
213
- assert_equal 200, res.status
214
- end
215
-
216
- def test_quick_missing
217
- data = StringIO.new "GET /quick/Marshal.4.8/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
218
- @req.parse data
219
-
220
- @server.quick @req, @res
221
-
222
- assert_equal 404, @res.status, @res.body
223
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
224
- assert_equal 'text/plain', @res['content-type']
225
- assert_equal 'No gems found matching "z-9"', @res.body
226
- assert_equal 404, @res.status
227
- end
228
-
229
- def test_quick_marshal_a_1_gemspec_rz
230
- data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
231
- @req.parse data
232
-
233
- @server.quick @req, @res
234
-
235
- assert_equal 200, @res.status, @res.body
236
- assert @res['date']
237
- assert_equal 'application/x-deflate', @res['content-type']
238
-
239
- spec = Marshal.load Gem::Util.inflate(@res.body)
240
- assert_equal 'a', spec.name
241
- assert_equal Gem::Version.new(1), spec.version
242
- end
243
-
244
- def test_quick_marshal_a_1_mswin32_gemspec_rz
245
- quick_gem 'a', '1' do |s|
246
- s.platform = Gem::Platform.local
247
- end
248
-
249
- data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
250
- @req.parse data
251
-
252
- @server.quick @req, @res
253
-
254
- assert_equal 200, @res.status, @res.body
255
- assert @res['date']
256
- assert_equal 'application/x-deflate', @res['content-type']
257
-
258
- spec = Marshal.load Gem::Util.inflate(@res.body)
259
- assert_equal 'a', spec.name
260
- assert_equal Gem::Version.new(1), spec.version
261
- assert_equal Gem::Platform.local, spec.platform
262
- end
263
-
264
- def test_quick_marshal_a_3_a_gemspec_rz
265
- data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-3.a.gemspec.rz HTTP/1.0\r\n\r\n"
266
- @req.parse data
267
-
268
- @server.quick @req, @res
269
-
270
- assert_equal 200, @res.status, @res.body
271
- assert @res['date']
272
- assert_equal 'application/x-deflate', @res['content-type']
273
-
274
- spec = Marshal.load Gem::Util.inflate(@res.body)
275
- assert_equal 'a', spec.name
276
- assert_equal v('3.a'), spec.version
277
- end
278
-
279
- def test_quick_marshal_a_b_3_a_gemspec_rz
280
- quick_gem 'a-b', '3.a'
281
-
282
- data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-b-3.a.gemspec.rz HTTP/1.0\r\n\r\n"
283
- @req.parse data
284
-
285
- @server.quick @req, @res
286
-
287
- assert_equal 200, @res.status, @res.body
288
- assert @res['date']
289
- assert_equal 'application/x-deflate', @res['content-type']
290
-
291
- spec = Marshal.load Gem::Util.inflate(@res.body)
292
- assert_equal 'a-b', spec.name
293
- assert_equal v('3.a'), spec.version
294
- end
295
-
296
- def test_quick_marshal_a_b_1_3_a_gemspec_rz
297
- quick_gem 'a-b-1', '3.a'
298
-
299
- data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-b-1-3.a.gemspec.rz HTTP/1.0\r\n\r\n"
300
- @req.parse data
301
-
302
- @server.quick @req, @res
303
-
304
- assert_equal 200, @res.status, @res.body
305
- assert @res['date']
306
- assert_equal 'application/x-deflate', @res['content-type']
307
-
308
- spec = Marshal.load Gem::Util.inflate(@res.body)
309
- assert_equal 'a-b-1', spec.name
310
- assert_equal v('3.a'), spec.version
311
- end
312
-
313
- def test_rdoc
314
- data = StringIO.new "GET /rdoc?q=a HTTP/1.0\r\n\r\n"
315
- @req.parse data
316
-
317
- @server.rdoc @req, @res
318
-
319
- assert_equal 200, @res.status, @res.body
320
- assert_match %r{No documentation found}, @res.body
321
- assert_equal 'text/html', @res['content-type']
322
- end
323
-
324
- def test_root
325
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
326
- @req.parse data
327
-
328
- @server.root @req, @res
329
-
330
- assert_equal 200, @res.status, @res.body
331
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
332
- assert_equal 'text/html', @res['content-type']
333
- end
334
-
335
- def test_root_gemdirs
336
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
337
- dir = "#{@gemhome}2"
338
-
339
- spec = util_spec 'z', 9
340
-
341
- specs_dir = File.join dir, 'specifications'
342
- FileUtils.mkdir_p specs_dir
343
-
344
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
345
- io.write spec.to_ruby
346
- end
347
-
348
- server = Gem::Server.new dir, process_based_port, false
349
-
350
- @req.parse data
351
-
352
- server.root @req, @res
353
-
354
- assert_equal 200, @res.status
355
- assert_match 'z 9', @res.body
356
- end
357
-
358
- def test_xss_homepage_fix_289313
359
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
360
- dir = "#{@gemhome}2"
361
-
362
- spec = util_spec 'xsshomepagegem', 1
363
- spec.homepage = "javascript:confirm(document.domain)"
364
-
365
- specs_dir = File.join dir, 'specifications'
366
- FileUtils.mkdir_p specs_dir
367
-
368
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
369
- io.write spec.to_ruby
370
- end
371
-
372
- server = Gem::Server.new dir, process_based_port, false
373
-
374
- @req.parse data
375
-
376
- server.root @req, @res
377
-
378
- assert_equal 200, @res.status
379
- assert_match 'xsshomepagegem 1', @res.body
380
-
381
- # This verifies that the homepage for this spec is not displayed and is set to ".", because it's not a
382
- # valid HTTP/HTTPS URL and could be unsafe in an HTML context. We would prefer to throw an exception here,
383
- # but spec.homepage is currently free form and not currently required to be a URL, this behavior may be
384
- # validated in future versions of Gem::Specification.
385
- #
386
- # There are two variant we're checking here, one where rdoc is not present, and one where rdoc is present in the same regex:
387
- #
388
- # Variant #1 - rdoc not installed
389
- #
390
- # <b>xsshomepagegem 1</b>
391
- #
392
- #
393
- # <span title="rdoc not installed">[rdoc]</span>
394
- #
395
- #
396
- #
397
- # <a href="." title=".">[www]</a>
398
- #
399
- # Variant #2 - rdoc installed
400
- #
401
- # <b>xsshomepagegem 1</b>
402
- #
403
- #
404
- # <a href="\/doc_root\/xsshomepagegem-1\/">\[rdoc\]<\/a>
405
- #
406
- #
407
- #
408
- # <a href="." title=".">[www]</a>
409
- regex_match = /xsshomepagegem 1<\/b>\s+(<span title="rdoc not installed">\[rdoc\]<\/span>|<a href="\/doc_root\/xsshomepagegem-1\/">\[rdoc\]<\/a>)\s+<a href="\." title="\.">\[www\]<\/a>/
410
- assert_match regex_match, @res.body
411
- end
412
-
413
- def test_invalid_homepage
414
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
415
- dir = "#{@gemhome}2"
416
-
417
- spec = util_spec 'invalidhomepagegem', 1
418
- spec.homepage = "notavalidhomepageurl"
419
-
420
- specs_dir = File.join dir, 'specifications'
421
- FileUtils.mkdir_p specs_dir
422
-
423
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
424
- io.write spec.to_ruby
425
- end
426
-
427
- server = Gem::Server.new dir, process_based_port, false
428
-
429
- @req.parse data
430
-
431
- server.root @req, @res
432
-
433
- assert_equal 200, @res.status
434
- assert_match 'invalidhomepagegem 1', @res.body
435
-
436
- # This verifies that the homepage for this spec is not displayed and is set to ".", because it's not a
437
- # valid HTTP/HTTPS URL and could be unsafe in an HTML context. We would prefer to throw an exception here,
438
- # but spec.homepage is currently free form and not currently required to be a URL, this behavior may be
439
- # validated in future versions of Gem::Specification.
440
- #
441
- # There are two variant we're checking here, one where rdoc is not present, and one where rdoc is present in the same regex:
442
- #
443
- # Variant #1 - rdoc not installed
444
- #
445
- # <b>invalidhomepagegem 1</b>
446
- #
447
- #
448
- # <span title="rdoc not installed">[rdoc]</span>
449
- #
450
- #
451
- #
452
- # <a href="." title=".">[www]</a>
453
- #
454
- # Variant #2 - rdoc installed
455
- #
456
- # <b>invalidhomepagegem 1</b>
457
- #
458
- #
459
- # <a href="\/doc_root\/invalidhomepagegem-1\/">\[rdoc\]<\/a>
460
- #
461
- #
462
- #
463
- # <a href="." title=".">[www]</a>
464
- regex_match = /invalidhomepagegem 1<\/b>\s+(<span title="rdoc not installed">\[rdoc\]<\/span>|<a href="\/doc_root\/invalidhomepagegem-1\/">\[rdoc\]<\/a>)\s+<a href="\." title="\.">\[www\]<\/a>/
465
- assert_match regex_match, @res.body
466
- end
467
-
468
- def test_valid_homepage_http
469
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
470
- dir = "#{@gemhome}2"
471
-
472
- spec = util_spec 'validhomepagegemhttp', 1
473
- spec.homepage = "http://rubygems.org"
474
-
475
- specs_dir = File.join dir, 'specifications'
476
- FileUtils.mkdir_p specs_dir
477
-
478
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
479
- io.write spec.to_ruby
480
- end
481
-
482
- server = Gem::Server.new dir, process_based_port, false
483
-
484
- @req.parse data
485
-
486
- server.root @req, @res
487
-
488
- assert_equal 200, @res.status
489
- assert_match 'validhomepagegemhttp 1', @res.body
490
-
491
- regex_match = /validhomepagegemhttp 1<\/b>\s+(<span title="rdoc not installed">\[rdoc\]<\/span>|<a href="\/doc_root\/validhomepagegemhttp-1\/">\[rdoc\]<\/a>)\s+<a href="http:\/\/rubygems\.org" title="http:\/\/rubygems\.org">\[www\]<\/a>/
492
- assert_match regex_match, @res.body
493
- end
494
-
495
- def test_valid_homepage_https
496
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
497
- dir = "#{@gemhome}2"
498
-
499
- spec = util_spec 'validhomepagegemhttps', 1
500
- spec.homepage = "https://rubygems.org"
501
-
502
- specs_dir = File.join dir, 'specifications'
503
- FileUtils.mkdir_p specs_dir
504
-
505
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
506
- io.write spec.to_ruby
507
- end
508
-
509
- server = Gem::Server.new dir, process_based_port, false
510
-
511
- @req.parse data
512
-
513
- server.root @req, @res
514
-
515
- assert_equal 200, @res.status
516
- assert_match 'validhomepagegemhttps 1', @res.body
517
-
518
- regex_match = /validhomepagegemhttps 1<\/b>\s+(<span title="rdoc not installed">\[rdoc\]<\/span>|<a href="\/doc_root\/validhomepagegemhttps-1\/">\[rdoc\]<\/a>)\s+<a href="https:\/\/rubygems\.org" title="https:\/\/rubygems\.org">\[www\]<\/a>/
519
- assert_match regex_match, @res.body
520
- end
521
-
522
- def test_specs
523
- data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
524
- @req.parse data
525
-
526
- @server.specs @req, @res
527
-
528
- assert_equal 200, @res.status, @res.body
529
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
530
- assert_equal 'application/octet-stream', @res['content-type']
531
-
532
- assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
533
- ['a', Gem::Version.new(2), Gem::Platform::RUBY],
534
- ['a', v('3.a'), Gem::Platform::RUBY]],
535
- Marshal.load(@res.body)
536
- end
537
-
538
- def test_specs_gemdirs
539
- data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
540
- dir = "#{@gemhome}2"
541
-
542
- spec = util_spec 'z', 9
543
-
544
- specs_dir = File.join dir, 'specifications'
545
- FileUtils.mkdir_p specs_dir
546
-
547
- File.open File.join(specs_dir, spec.spec_name), 'w' do |io|
548
- io.write spec.to_ruby
549
- end
550
-
551
- server = Gem::Server.new dir, process_based_port, false
552
-
553
- @req.parse data
554
-
555
- server.specs @req, @res
556
-
557
- assert_equal 200, @res.status
558
-
559
- assert_equal [['z', v(9), Gem::Platform::RUBY]], Marshal.load(@res.body)
560
- end
561
-
562
- def test_specs_gz
563
- data = StringIO.new "GET /specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
564
- @req.parse data
565
-
566
- @server.specs @req, @res
567
-
568
- assert_equal 200, @res.status, @res.body
569
- assert_match %r{ \d\d:\d\d:\d\d }, @res['date']
570
- assert_equal 'application/x-gzip', @res['content-type']
571
-
572
- assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
573
- ['a', Gem::Version.new(2), Gem::Platform::RUBY],
574
- ['a', v('3.a'), Gem::Platform::RUBY]],
575
- Marshal.load(Gem::Util.gunzip(@res.body))
576
- end
577
-
578
- def test_uri_encode
579
- url_safe = @server.uri_encode 'http://rubyonrails.org/">malicious_content</a>'
580
- assert_equal url_safe, 'http://rubyonrails.org/%22%3Emalicious_content%3C/a%3E'
581
- end
582
-
583
- # Regression test for issue #1793: incorrect URL encoding.
584
- # Checking that no URLs have had '://' incorrectly encoded
585
- def test_regression_1793
586
- data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
587
- @req.parse data
588
-
589
- @server.root @req, @res
590
-
591
- refute_match %r{%3A%2F%2F}, @res.body
592
- end
593
-
594
- def util_listen
595
- webrick = Object.new
596
- webrick.instance_variable_set :@listeners, []
597
- def webrick.listeners() @listeners end
598
- def webrick.listen(host, port)
599
- socket = Object.new
600
- socket.instance_variable_set :@host, host
601
- socket.instance_variable_set :@port, port
602
- def socket.addr() [nil, @port, @host] end
603
- @listeners << socket
604
- end
605
-
606
- @server.instance_variable_set :@server, webrick
607
- end
608
- end