rubygems-update 3.1.0.pre3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +43 -0
  6. data/History.txt +97 -2
  7. data/Manifest.txt +21 -3
  8. data/README.md +4 -4
  9. data/Rakefile +11 -10
  10. data/bin/update_rubygems +1 -1
  11. data/bundler/CHANGELOG.md +56 -3
  12. data/bundler/lib/bundler.rb +0 -1
  13. data/bundler/lib/bundler/build_metadata.rb +2 -0
  14. data/bundler/lib/bundler/cli.rb +1 -1
  15. data/bundler/lib/bundler/cli/config.rb +1 -1
  16. data/bundler/lib/bundler/cli/install.rb +3 -2
  17. data/bundler/lib/bundler/cli/update.rb +1 -1
  18. data/bundler/lib/bundler/feature_flag.rb +1 -1
  19. data/bundler/lib/bundler/fetcher.rb +2 -2
  20. data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
  21. data/bundler/lib/bundler/fetcher/index.rb +1 -1
  22. data/bundler/lib/bundler/friendly_errors.rb +1 -1
  23. data/bundler/lib/bundler/gem_helper.rb +13 -12
  24. data/bundler/lib/bundler/inline.rb +36 -31
  25. data/bundler/lib/bundler/lazy_specification.rb +0 -1
  26. data/bundler/lib/bundler/mirror.rb +3 -3
  27. data/bundler/lib/bundler/plugin/api/source.rb +2 -4
  28. data/bundler/lib/bundler/remote_specification.rb +0 -2
  29. data/bundler/lib/bundler/rubygems_integration.rb +15 -13
  30. data/bundler/lib/bundler/settings.rb +7 -4
  31. data/bundler/lib/bundler/setup.rb +5 -0
  32. data/bundler/lib/bundler/source/git.rb +5 -5
  33. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -2
  34. data/bundler/lib/bundler/source/rubygems.rb +3 -3
  35. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  36. data/bundler/lib/bundler/uri_credentials_filter.rb +7 -3
  37. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +3 -3
  38. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +26 -48
  39. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +7 -0
  40. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +10 -6
  41. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +29 -19
  42. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  43. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +1 -1
  44. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +13 -2
  45. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +8 -9
  46. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
  47. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +2 -2
  48. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +17 -1
  49. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  50. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  51. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  52. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  53. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  54. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  55. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  56. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  57. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  58. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  59. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  60. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  61. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  62. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  63. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  64. data/bundler/lib/bundler/version.rb +1 -1
  65. data/bundler/man/bundle-add.1 +1 -1
  66. data/bundler/man/bundle-add.1.txt +1 -1
  67. data/bundler/man/bundle-binstubs.1 +1 -1
  68. data/bundler/man/bundle-binstubs.1.txt +1 -1
  69. data/bundler/man/bundle-cache.1 +1 -1
  70. data/bundler/man/bundle-cache.1.txt +1 -1
  71. data/bundler/man/bundle-check.1 +1 -1
  72. data/bundler/man/bundle-check.1.txt +1 -1
  73. data/bundler/man/bundle-clean.1 +1 -1
  74. data/bundler/man/bundle-clean.1.txt +1 -1
  75. data/bundler/man/bundle-config.1 +1 -1
  76. data/bundler/man/bundle-config.1.txt +1 -1
  77. data/bundler/man/bundle-doctor.1 +1 -1
  78. data/bundler/man/bundle-doctor.1.txt +1 -1
  79. data/bundler/man/bundle-exec.1 +1 -1
  80. data/bundler/man/bundle-exec.1.txt +1 -1
  81. data/bundler/man/bundle-gem.1 +1 -1
  82. data/bundler/man/bundle-gem.1.txt +1 -1
  83. data/bundler/man/bundle-info.1 +1 -1
  84. data/bundler/man/bundle-info.1.txt +1 -1
  85. data/bundler/man/bundle-init.1 +1 -1
  86. data/bundler/man/bundle-init.1.txt +1 -1
  87. data/bundler/man/bundle-inject.1 +1 -1
  88. data/bundler/man/bundle-inject.1.txt +1 -1
  89. data/bundler/man/bundle-install.1 +1 -1
  90. data/bundler/man/bundle-install.1.txt +1 -1
  91. data/bundler/man/bundle-list.1 +1 -1
  92. data/bundler/man/bundle-list.1.txt +1 -1
  93. data/bundler/man/bundle-lock.1 +1 -1
  94. data/bundler/man/bundle-lock.1.txt +1 -1
  95. data/bundler/man/bundle-open.1 +1 -1
  96. data/bundler/man/bundle-open.1.txt +1 -1
  97. data/bundler/man/bundle-outdated.1 +1 -1
  98. data/bundler/man/bundle-outdated.1.txt +1 -1
  99. data/bundler/man/bundle-platform.1 +1 -1
  100. data/bundler/man/bundle-platform.1.txt +1 -1
  101. data/bundler/man/bundle-pristine.1 +1 -1
  102. data/bundler/man/bundle-pristine.1.txt +1 -1
  103. data/bundler/man/bundle-remove.1 +1 -1
  104. data/bundler/man/bundle-remove.1.txt +1 -1
  105. data/bundler/man/bundle-show.1 +1 -1
  106. data/bundler/man/bundle-show.1.txt +1 -1
  107. data/bundler/man/bundle-update.1 +1 -1
  108. data/bundler/man/bundle-update.1.txt +1 -1
  109. data/bundler/man/bundle-viz.1 +1 -1
  110. data/bundler/man/bundle-viz.1.txt +1 -1
  111. data/bundler/man/bundle.1 +1 -1
  112. data/bundler/man/bundle.1.txt +1 -1
  113. data/bundler/man/gemfile.5 +1 -1
  114. data/bundler/man/gemfile.5.txt +1 -1
  115. data/lib/rubygems.rb +64 -47
  116. data/lib/rubygems/basic_specification.rb +1 -1
  117. data/lib/rubygems/command.rb +29 -7
  118. data/lib/rubygems/commands/generate_index_command.rb +3 -0
  119. data/lib/rubygems/commands/help_command.rb +1 -1
  120. data/lib/rubygems/commands/setup_command.rb +30 -15
  121. data/lib/rubygems/commands/sources_command.rb +17 -3
  122. data/lib/rubygems/commands/uninstall_command.rb +1 -1
  123. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  124. data/lib/rubygems/core_ext/kernel_warn.rb +8 -4
  125. data/lib/rubygems/ext/builder.rb +4 -2
  126. data/lib/rubygems/remote_fetcher.rb +20 -31
  127. data/lib/rubygems/request.rb +2 -0
  128. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  129. data/lib/rubygems/resolver/api_set.rb +1 -1
  130. data/lib/rubygems/resolver/api_specification.rb +1 -1
  131. data/lib/rubygems/server.rb +1 -1
  132. data/lib/rubygems/source.rb +7 -1
  133. data/lib/rubygems/source_list.rb +2 -0
  134. data/lib/rubygems/specification.rb +12 -8
  135. data/lib/rubygems/specification_policy.rb +53 -30
  136. data/lib/rubygems/test_case.rb +60 -0
  137. data/lib/rubygems/uri_formatter.rb +0 -1
  138. data/lib/rubygems/uri_parser.rb +36 -0
  139. data/lib/rubygems/uri_parsing.rb +23 -0
  140. data/lib/rubygems/util.rb +7 -1
  141. data/lib/rubygems/version.rb +1 -1
  142. data/rubygems-update.gemspec +1 -8
  143. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +14 -0
  144. data/test/rubygems/test_gem.rb +90 -46
  145. data/test/rubygems/test_gem_command.rb +38 -9
  146. data/test/rubygems/test_gem_commands_build_command.rb +18 -1
  147. data/test/rubygems/test_gem_commands_generate_index_command.rb +37 -1
  148. data/test/rubygems/test_gem_commands_help_command.rb +1 -6
  149. data/test/rubygems/test_gem_commands_server_command.rb +6 -2
  150. data/test/rubygems/test_gem_commands_setup_command.rb +56 -10
  151. data/test/rubygems/test_gem_commands_sources_command.rb +113 -1
  152. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -0
  153. data/test/rubygems/test_gem_gem_runner.rb +3 -1
  154. data/test/rubygems/test_gem_indexer.rb +1 -1
  155. data/test/rubygems/test_gem_installer.rb +10 -23
  156. data/test/rubygems/test_gem_package.rb +3 -8
  157. data/test/rubygems/test_gem_package_tar_writer.rb +5 -0
  158. data/test/rubygems/test_gem_request_set.rb +52 -0
  159. data/test/rubygems/test_gem_source.rb +14 -0
  160. data/test/rubygems/test_gem_specification.rb +74 -54
  161. data/test/rubygems/test_gem_stub_specification.rb +0 -1
  162. data/test/rubygems/test_project_sanity.rb +0 -43
  163. data/test/rubygems/test_remote_fetch_error.rb +1 -1
  164. data/test/rubygems/test_require.rb +41 -42
  165. data/util/bisect +0 -21
  166. data/util/ci.sh +1 -1
  167. data/util/update_changelog.rb +7 -10
  168. metadata +27 -93
  169. data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
  170. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
  171. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: false
2
+ # = uri/http.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'generic'
12
+
13
+ module Bundler::URI
14
+
15
+ #
16
+ # The syntax of HTTP URIs is defined in RFC1738 section 3.3.
17
+ #
18
+ # Note that the Ruby Bundler::URI library allows HTTP URLs containing usernames and
19
+ # passwords. This is not legal as per the RFC, but used to be
20
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
21
+ # update. See <URL:http://support.microsoft.com/kb/834489>.
22
+ #
23
+ class HTTP < Generic
24
+ # A Default port of 80 for Bundler::URI::HTTP.
25
+ DEFAULT_PORT = 80
26
+
27
+ # An Array of the available components for Bundler::URI::HTTP.
28
+ COMPONENT = %i[
29
+ scheme
30
+ userinfo host port
31
+ path
32
+ query
33
+ fragment
34
+ ].freeze
35
+
36
+ #
37
+ # == Description
38
+ #
39
+ # Creates a new Bundler::URI::HTTP object from components, with syntax checking.
40
+ #
41
+ # The components accepted are userinfo, host, port, path, query, and
42
+ # fragment.
43
+ #
44
+ # The components should be provided either as an Array, or as a Hash
45
+ # with keys formed by preceding the component names with a colon.
46
+ #
47
+ # If an Array is used, the components must be passed in the
48
+ # order <code>[userinfo, host, port, path, query, fragment]</code>.
49
+ #
50
+ # Example:
51
+ #
52
+ # uri = Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
53
+ #
54
+ # uri = Bundler::URI::HTTP.build([nil, "www.example.com", nil, "/path",
55
+ # "query", 'fragment'])
56
+ #
57
+ # Currently, if passed userinfo components this method generates
58
+ # invalid HTTP URIs as per RFC 1738.
59
+ #
60
+ def self.build(args)
61
+ tmp = Util.make_components_hash(self, args)
62
+ super(tmp)
63
+ end
64
+
65
+ #
66
+ # == Description
67
+ #
68
+ # Returns the full path for an HTTP request, as required by Net::HTTP::Get.
69
+ #
70
+ # If the Bundler::URI contains a query, the full path is Bundler::URI#path + '?' + Bundler::URI#query.
71
+ # Otherwise, the path is simply Bundler::URI#path.
72
+ #
73
+ # Example:
74
+ #
75
+ # uri = Bundler::URI::HTTP.build(path: '/foo/bar', query: 'test=true')
76
+ # uri.request_uri # => "/foo/bar?test=true"
77
+ #
78
+ def request_uri
79
+ return unless @path
80
+
81
+ url = @query ? "#@path?#@query" : @path.dup
82
+ url.start_with?(?/.freeze) ? url : ?/ + url
83
+ end
84
+ end
85
+
86
+ @@schemes['HTTP'] = HTTP
87
+
88
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: false
2
+ # = uri/https.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'http'
12
+
13
+ module Bundler::URI
14
+
15
+ # The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
16
+ # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
17
+ # see Bundler::URI::HTTP.
18
+ class HTTPS < HTTP
19
+ # A Default port of 443 for Bundler::URI::HTTPS
20
+ DEFAULT_PORT = 443
21
+ end
22
+ @@schemes['HTTPS'] = HTTPS
23
+ end
@@ -0,0 +1,261 @@
1
+ # frozen_string_literal: false
2
+ # = uri/ldap.rb
3
+ #
4
+ # Author::
5
+ # Takaaki Tateishi <ttate@jaist.ac.jp>
6
+ # Akira Yamada <akira@ruby-lang.org>
7
+ # License::
8
+ # Bundler::URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
9
+ # You can redistribute it and/or modify it under the same term as Ruby.
10
+ # Revision:: $Id$
11
+ #
12
+ # See Bundler::URI for general documentation
13
+ #
14
+
15
+ require_relative 'generic'
16
+
17
+ module Bundler::URI
18
+
19
+ #
20
+ # LDAP Bundler::URI SCHEMA (described in RFC2255).
21
+ #--
22
+ # ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
23
+ #++
24
+ class LDAP < Generic
25
+
26
+ # A Default port of 389 for Bundler::URI::LDAP.
27
+ DEFAULT_PORT = 389
28
+
29
+ # An Array of the available components for Bundler::URI::LDAP.
30
+ COMPONENT = [
31
+ :scheme,
32
+ :host, :port,
33
+ :dn,
34
+ :attributes,
35
+ :scope,
36
+ :filter,
37
+ :extensions,
38
+ ].freeze
39
+
40
+ # Scopes available for the starting point.
41
+ #
42
+ # * SCOPE_BASE - the Base DN
43
+ # * SCOPE_ONE - one level under the Base DN, not including the base DN and
44
+ # not including any entries under this
45
+ # * SCOPE_SUB - subtrees, all entries at all levels
46
+ #
47
+ SCOPE = [
48
+ SCOPE_ONE = 'one',
49
+ SCOPE_SUB = 'sub',
50
+ SCOPE_BASE = 'base',
51
+ ].freeze
52
+
53
+ #
54
+ # == Description
55
+ #
56
+ # Creates a new Bundler::URI::LDAP object from components, with syntax checking.
57
+ #
58
+ # The components accepted are host, port, dn, attributes,
59
+ # scope, filter, and extensions.
60
+ #
61
+ # The components should be provided either as an Array, or as a Hash
62
+ # with keys formed by preceding the component names with a colon.
63
+ #
64
+ # If an Array is used, the components must be passed in the
65
+ # order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
66
+ #
67
+ # Example:
68
+ #
69
+ # uri = Bundler::URI::LDAP.build({:host => 'ldap.example.com',
70
+ # :dn => '/dc=example'})
71
+ #
72
+ # uri = Bundler::URI::LDAP.build(["ldap.example.com", nil,
73
+ # "/dc=example;dc=com", "query", nil, nil, nil])
74
+ #
75
+ def self.build(args)
76
+ tmp = Util::make_components_hash(self, args)
77
+
78
+ if tmp[:dn]
79
+ tmp[:path] = tmp[:dn]
80
+ end
81
+
82
+ query = []
83
+ [:extensions, :filter, :scope, :attributes].collect do |x|
84
+ next if !tmp[x] && query.size == 0
85
+ query.unshift(tmp[x])
86
+ end
87
+
88
+ tmp[:query] = query.join('?')
89
+
90
+ return super(tmp)
91
+ end
92
+
93
+ #
94
+ # == Description
95
+ #
96
+ # Creates a new Bundler::URI::LDAP object from generic Bundler::URI components as per
97
+ # RFC 2396. No LDAP-specific syntax checking is performed.
98
+ #
99
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
100
+ # +opaque+, +query+, and +fragment+, in that order.
101
+ #
102
+ # Example:
103
+ #
104
+ # uri = Bundler::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
105
+ # "/dc=example;dc=com", nil, "query", nil)
106
+ #
107
+ # See also Bundler::URI::Generic.new.
108
+ #
109
+ def initialize(*arg)
110
+ super(*arg)
111
+
112
+ if @fragment
113
+ raise InvalidURIError, 'bad LDAP URL'
114
+ end
115
+
116
+ parse_dn
117
+ parse_query
118
+ end
119
+
120
+ # Private method to cleanup +dn+ from using the +path+ component attribute.
121
+ def parse_dn
122
+ @dn = @path[1..-1]
123
+ end
124
+ private :parse_dn
125
+
126
+ # Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
127
+ # from using the +query+ component attribute.
128
+ def parse_query
129
+ @attributes = nil
130
+ @scope = nil
131
+ @filter = nil
132
+ @extensions = nil
133
+
134
+ if @query
135
+ attrs, scope, filter, extensions = @query.split('?')
136
+
137
+ @attributes = attrs if attrs && attrs.size > 0
138
+ @scope = scope if scope && scope.size > 0
139
+ @filter = filter if filter && filter.size > 0
140
+ @extensions = extensions if extensions && extensions.size > 0
141
+ end
142
+ end
143
+ private :parse_query
144
+
145
+ # Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
146
+ def build_path_query
147
+ @path = '/' + @dn
148
+
149
+ query = []
150
+ [@extensions, @filter, @scope, @attributes].each do |x|
151
+ next if !x && query.size == 0
152
+ query.unshift(x)
153
+ end
154
+ @query = query.join('?')
155
+ end
156
+ private :build_path_query
157
+
158
+ # Returns dn.
159
+ def dn
160
+ @dn
161
+ end
162
+
163
+ # Private setter for dn +val+.
164
+ def set_dn(val)
165
+ @dn = val
166
+ build_path_query
167
+ @dn
168
+ end
169
+ protected :set_dn
170
+
171
+ # Setter for dn +val+.
172
+ def dn=(val)
173
+ set_dn(val)
174
+ val
175
+ end
176
+
177
+ # Returns attributes.
178
+ def attributes
179
+ @attributes
180
+ end
181
+
182
+ # Private setter for attributes +val+.
183
+ def set_attributes(val)
184
+ @attributes = val
185
+ build_path_query
186
+ @attributes
187
+ end
188
+ protected :set_attributes
189
+
190
+ # Setter for attributes +val+.
191
+ def attributes=(val)
192
+ set_attributes(val)
193
+ val
194
+ end
195
+
196
+ # Returns scope.
197
+ def scope
198
+ @scope
199
+ end
200
+
201
+ # Private setter for scope +val+.
202
+ def set_scope(val)
203
+ @scope = val
204
+ build_path_query
205
+ @scope
206
+ end
207
+ protected :set_scope
208
+
209
+ # Setter for scope +val+.
210
+ def scope=(val)
211
+ set_scope(val)
212
+ val
213
+ end
214
+
215
+ # Returns filter.
216
+ def filter
217
+ @filter
218
+ end
219
+
220
+ # Private setter for filter +val+.
221
+ def set_filter(val)
222
+ @filter = val
223
+ build_path_query
224
+ @filter
225
+ end
226
+ protected :set_filter
227
+
228
+ # Setter for filter +val+.
229
+ def filter=(val)
230
+ set_filter(val)
231
+ val
232
+ end
233
+
234
+ # Returns extensions.
235
+ def extensions
236
+ @extensions
237
+ end
238
+
239
+ # Private setter for extensions +val+.
240
+ def set_extensions(val)
241
+ @extensions = val
242
+ build_path_query
243
+ @extensions
244
+ end
245
+ protected :set_extensions
246
+
247
+ # Setter for extensions +val+.
248
+ def extensions=(val)
249
+ set_extensions(val)
250
+ val
251
+ end
252
+
253
+ # Checks if Bundler::URI has a path.
254
+ # For Bundler::URI::LDAP this will return +false+.
255
+ def hierarchical?
256
+ false
257
+ end
258
+ end
259
+
260
+ @@schemes['LDAP'] = LDAP
261
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: false
2
+ # = uri/ldap.rb
3
+ #
4
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
5
+ #
6
+ # See Bundler::URI for general documentation
7
+ #
8
+
9
+ require_relative 'ldap'
10
+
11
+ module Bundler::URI
12
+
13
+ # The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
14
+ # than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
15
+ # see Bundler::URI::LDAP.
16
+ class LDAPS < LDAP
17
+ # A Default port of 636 for Bundler::URI::LDAPS
18
+ DEFAULT_PORT = 636
19
+ end
20
+ @@schemes['LDAPS'] = LDAPS
21
+ end
@@ -0,0 +1,294 @@
1
+ # frozen_string_literal: false
2
+ # = uri/mailto.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'generic'
12
+
13
+ module Bundler::URI
14
+
15
+ #
16
+ # RFC6068, the mailto URL scheme.
17
+ #
18
+ class MailTo < Generic
19
+ include REGEXP
20
+
21
+ # A Default port of nil for Bundler::URI::MailTo.
22
+ DEFAULT_PORT = nil
23
+
24
+ # An Array of the available components for Bundler::URI::MailTo.
25
+ COMPONENT = [ :scheme, :to, :headers ].freeze
26
+
27
+ # :stopdoc:
28
+ # "hname" and "hvalue" are encodings of an RFC 822 header name and
29
+ # value, respectively. As with "to", all URL reserved characters must
30
+ # be encoded.
31
+ #
32
+ # "#mailbox" is as specified in RFC 822 [RFC822]. This means that it
33
+ # consists of zero or more comma-separated mail addresses, possibly
34
+ # including "phrase" and "comment" components. Note that all URL
35
+ # reserved characters in "to" must be encoded: in particular,
36
+ # parentheses, commas, and the percent sign ("%"), which commonly occur
37
+ # in the "mailbox" syntax.
38
+ #
39
+ # Within mailto URLs, the characters "?", "=", "&" are reserved.
40
+
41
+ # ; RFC 6068
42
+ # hfields = "?" hfield *( "&" hfield )
43
+ # hfield = hfname "=" hfvalue
44
+ # hfname = *qchar
45
+ # hfvalue = *qchar
46
+ # qchar = unreserved / pct-encoded / some-delims
47
+ # some-delims = "!" / "$" / "'" / "(" / ")" / "*"
48
+ # / "+" / "," / ";" / ":" / "@"
49
+ #
50
+ # ; RFC3986
51
+ # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
52
+ # pct-encoded = "%" HEXDIG HEXDIG
53
+ HEADER_REGEXP = /\A(?<hfield>(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g<hfield>)*\z/
54
+ # practical regexp for email address
55
+ # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
56
+ EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
57
+ # :startdoc:
58
+
59
+ #
60
+ # == Description
61
+ #
62
+ # Creates a new Bundler::URI::MailTo object from components, with syntax checking.
63
+ #
64
+ # Components can be provided as an Array or Hash. If an Array is used,
65
+ # the components must be supplied as <code>[to, headers]</code>.
66
+ #
67
+ # If a Hash is used, the keys are the component names preceded by colons.
68
+ #
69
+ # The headers can be supplied as a pre-encoded string, such as
70
+ # <code>"subject=subscribe&cc=address"</code>, or as an Array of Arrays
71
+ # like <code>[['subject', 'subscribe'], ['cc', 'address']]</code>.
72
+ #
73
+ # Examples:
74
+ #
75
+ # require 'bundler/vendor/uri/lib/uri'
76
+ #
77
+ # m1 = Bundler::URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
78
+ # m1.to_s # => "mailto:joe@example.com?subject=Ruby"
79
+ #
80
+ # m2 = Bundler::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
81
+ # m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
82
+ #
83
+ # m3 = Bundler::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
84
+ # m3.to_s # => "mailto:listman@example.com?subject=subscribe"
85
+ #
86
+ def self.build(args)
87
+ tmp = Util.make_components_hash(self, args)
88
+
89
+ case tmp[:to]
90
+ when Array
91
+ tmp[:opaque] = tmp[:to].join(',')
92
+ when String
93
+ tmp[:opaque] = tmp[:to].dup
94
+ else
95
+ tmp[:opaque] = ''
96
+ end
97
+
98
+ if tmp[:headers]
99
+ query =
100
+ case tmp[:headers]
101
+ when Array
102
+ tmp[:headers].collect { |x|
103
+ if x.kind_of?(Array)
104
+ x[0] + '=' + x[1..-1].join
105
+ else
106
+ x.to_s
107
+ end
108
+ }.join('&')
109
+ when Hash
110
+ tmp[:headers].collect { |h,v|
111
+ h + '=' + v
112
+ }.join('&')
113
+ else
114
+ tmp[:headers].to_s
115
+ end
116
+ unless query.empty?
117
+ tmp[:opaque] << '?' << query
118
+ end
119
+ end
120
+
121
+ super(tmp)
122
+ end
123
+
124
+ #
125
+ # == Description
126
+ #
127
+ # Creates a new Bundler::URI::MailTo object from generic URL components with
128
+ # no syntax checking.
129
+ #
130
+ # This method is usually called from Bundler::URI::parse, which checks
131
+ # the validity of each component.
132
+ #
133
+ def initialize(*arg)
134
+ super(*arg)
135
+
136
+ @to = nil
137
+ @headers = []
138
+
139
+ # The RFC3986 parser does not normally populate opaque
140
+ @opaque = "?#{@query}" if @query && !@opaque
141
+
142
+ unless @opaque
143
+ raise InvalidComponentError,
144
+ "missing opaque part for mailto URL"
145
+ end
146
+ to, header = @opaque.split('?', 2)
147
+ # allow semicolon as a addr-spec separator
148
+ # http://support.microsoft.com/kb/820868
149
+ unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to
150
+ raise InvalidComponentError,
151
+ "unrecognised opaque part for mailtoURL: #{@opaque}"
152
+ end
153
+
154
+ if arg[10] # arg_check
155
+ self.to = to
156
+ self.headers = header
157
+ else
158
+ set_to(to)
159
+ set_headers(header)
160
+ end
161
+ end
162
+
163
+ # The primary e-mail address of the URL, as a String.
164
+ attr_reader :to
165
+
166
+ # E-mail headers set by the URL, as an Array of Arrays.
167
+ attr_reader :headers
168
+
169
+ # Checks the to +v+ component.
170
+ def check_to(v)
171
+ return true unless v
172
+ return true if v.size == 0
173
+
174
+ v.split(/[,;]/).each do |addr|
175
+ # check url safety as path-rootless
176
+ if /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*\z/ !~ addr
177
+ raise InvalidComponentError,
178
+ "an address in 'to' is invalid as Bundler::URI #{addr.dump}"
179
+ end
180
+
181
+ # check addr-spec
182
+ # don't s/\+/ /g
183
+ addr.gsub!(/%\h\h/, Bundler::URI::TBLDECWWWCOMP_)
184
+ if EMAIL_REGEXP !~ addr
185
+ raise InvalidComponentError,
186
+ "an address in 'to' is invalid as uri-escaped addr-spec #{addr.dump}"
187
+ end
188
+ end
189
+
190
+ true
191
+ end
192
+ private :check_to
193
+
194
+ # Private setter for to +v+.
195
+ def set_to(v)
196
+ @to = v
197
+ end
198
+ protected :set_to
199
+
200
+ # Setter for to +v+.
201
+ def to=(v)
202
+ check_to(v)
203
+ set_to(v)
204
+ v
205
+ end
206
+
207
+ # Checks the headers +v+ component against either
208
+ # * HEADER_REGEXP
209
+ def check_headers(v)
210
+ return true unless v
211
+ return true if v.size == 0
212
+ if HEADER_REGEXP !~ v
213
+ raise InvalidComponentError,
214
+ "bad component(expected opaque component): #{v}"
215
+ end
216
+
217
+ true
218
+ end
219
+ private :check_headers
220
+
221
+ # Private setter for headers +v+.
222
+ def set_headers(v)
223
+ @headers = []
224
+ if v
225
+ v.split('&').each do |x|
226
+ @headers << x.split(/=/, 2)
227
+ end
228
+ end
229
+ end
230
+ protected :set_headers
231
+
232
+ # Setter for headers +v+.
233
+ def headers=(v)
234
+ check_headers(v)
235
+ set_headers(v)
236
+ v
237
+ end
238
+
239
+ # Constructs String from Bundler::URI.
240
+ def to_s
241
+ @scheme + ':' +
242
+ if @to
243
+ @to
244
+ else
245
+ ''
246
+ end +
247
+ if @headers.size > 0
248
+ '?' + @headers.collect{|x| x.join('=')}.join('&')
249
+ else
250
+ ''
251
+ end +
252
+ if @fragment
253
+ '#' + @fragment
254
+ else
255
+ ''
256
+ end
257
+ end
258
+
259
+ # Returns the RFC822 e-mail text equivalent of the URL, as a String.
260
+ #
261
+ # Example:
262
+ #
263
+ # require 'bundler/vendor/uri/lib/uri'
264
+ #
265
+ # uri = Bundler::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
266
+ # uri.to_mailtext
267
+ # # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
268
+ #
269
+ def to_mailtext
270
+ to = Bundler::URI.decode_www_form_component(@to)
271
+ head = ''
272
+ body = ''
273
+ @headers.each do |x|
274
+ case x[0]
275
+ when 'body'
276
+ body = Bundler::URI.decode_www_form_component(x[1])
277
+ when 'to'
278
+ to << ', ' + Bundler::URI.decode_www_form_component(x[1])
279
+ else
280
+ head << Bundler::URI.decode_www_form_component(x[0]).capitalize + ': ' +
281
+ Bundler::URI.decode_www_form_component(x[1]) + "\n"
282
+ end
283
+ end
284
+
285
+ "To: #{to}
286
+ #{head}
287
+ #{body}
288
+ "
289
+ end
290
+ alias to_rfc822text to_mailtext
291
+ end
292
+
293
+ @@schemes['MAILTO'] = MailTo
294
+ end