bundler 2.2.29 → 2.5.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1129 -4
- data/README.md +4 -8
- data/bundler.gemspec +11 -11
- data/exe/bundle +5 -26
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +4 -4
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +4 -4
- data/lib/bundler/cli/binstubs.rb +10 -6
- data/lib/bundler/cli/cache.rb +1 -1
- data/lib/bundler/cli/check.rb +3 -3
- data/lib/bundler/cli/common.rb +13 -3
- data/lib/bundler/cli/config.rb +18 -8
- data/lib/bundler/cli/console.rb +5 -4
- data/lib/bundler/cli/doctor.rb +12 -5
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/fund.rb +1 -1
- data/lib/bundler/cli/gem.rb +141 -48
- data/lib/bundler/cli/info.rb +27 -17
- data/lib/bundler/cli/init.rb +6 -2
- data/lib/bundler/cli/install.rb +22 -39
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/lock.rb +36 -29
- data/lib/bundler/cli/open.rb +9 -9
- data/lib/bundler/cli/outdated.rb +19 -12
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +9 -15
- data/lib/bundler/cli/pristine.rb +38 -30
- data/lib/bundler/cli/show.rb +3 -3
- data/lib/bundler/cli/update.rb +12 -7
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +266 -285
- data/lib/bundler/compact_index_client/cache.rb +53 -67
- data/lib/bundler/compact_index_client/cache_file.rb +153 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +83 -76
- data/lib/bundler/compact_index_client.rb +59 -87
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +12 -16
- data/lib/bundler/definition.rb +509 -319
- data/lib/bundler/dependency.rb +33 -71
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +88 -69
- data/lib/bundler/endpoint_specification.rb +32 -15
- data/lib/bundler/env.rb +5 -7
- data/lib/bundler/environment_preserver.rb +8 -22
- data/lib/bundler/errors.rb +101 -13
- data/lib/bundler/feature_flag.rb +0 -2
- data/lib/bundler/fetcher/base.rb +11 -11
- data/lib/bundler/fetcher/compact_index.rb +32 -52
- data/lib/bundler/fetcher/dependency.rb +3 -7
- data/lib/bundler/fetcher/downloader.rb +17 -16
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +2 -29
- data/lib/bundler/fetcher.rb +87 -79
- data/lib/bundler/force_platform.rb +18 -0
- data/lib/bundler/friendly_errors.rb +29 -40
- data/lib/bundler/gem_helper.rb +11 -23
- data/lib/bundler/gem_helpers.rb +30 -6
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +9 -9
- data/lib/bundler/index.rb +71 -79
- data/lib/bundler/injector.rb +23 -11
- data/lib/bundler/inline.rb +11 -23
- data/lib/bundler/installer/gem_installer.rb +18 -11
- data/lib/bundler/installer/parallel_installer.rb +17 -65
- data/lib/bundler/installer/standalone.rb +56 -15
- data/lib/bundler/installer.rb +35 -61
- data/lib/bundler/lazy_specification.rb +92 -61
- data/lib/bundler/lockfile_generator.rb +12 -3
- data/lib/bundler/lockfile_parser.rb +137 -70
- data/lib/bundler/man/bundle-add.1 +19 -26
- data/lib/bundler/man/bundle-add.1.ronn +16 -4
- data/lib/bundler/man/bundle-binstubs.1 +4 -16
- data/lib/bundler/man/bundle-cache.1 +9 -24
- data/lib/bundler/man/bundle-cache.1.ronn +9 -2
- data/lib/bundler/man/bundle-check.1 +5 -12
- data/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/lib/bundler/man/bundle-clean.1 +4 -11
- data/lib/bundler/man/bundle-clean.1.ronn +1 -1
- data/lib/bundler/man/bundle-config.1 +47 -224
- data/lib/bundler/man/bundle-config.1.ronn +40 -28
- data/lib/bundler/man/bundle-console.1 +35 -0
- data/lib/bundler/man/bundle-console.1.ronn +44 -0
- data/lib/bundler/man/bundle-doctor.1 +4 -18
- data/lib/bundler/man/bundle-exec.1 +16 -77
- data/lib/bundler/man/bundle-exec.1.ronn +8 -9
- data/lib/bundler/man/bundle-gem.1 +45 -72
- data/lib/bundler/man/bundle-gem.1.ronn +32 -5
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +5 -11
- data/lib/bundler/man/bundle-info.1.ronn +3 -3
- data/lib/bundler/man/bundle-init.1 +6 -11
- data/lib/bundler/man/bundle-init.1.ronn +2 -0
- data/lib/bundler/man/bundle-inject.1 +8 -18
- data/lib/bundler/man/bundle-inject.1.ronn +3 -1
- data/lib/bundler/man/bundle-install.1 +32 -155
- data/lib/bundler/man/bundle-install.1.ronn +11 -33
- data/lib/bundler/man/bundle-list.1 +4 -19
- data/lib/bundler/man/bundle-lock.1 +5 -29
- data/lib/bundler/man/bundle-open.1 +18 -18
- data/lib/bundler/man/bundle-open.1.ronn +9 -1
- data/lib/bundler/man/bundle-outdated.1 +17 -72
- data/lib/bundler/man/bundle-outdated.1.ronn +13 -18
- data/lib/bundler/man/bundle-platform.1 +16 -28
- data/lib/bundler/man/bundle-platform.1.ronn +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/lib/bundler/man/bundle-pristine.1 +5 -16
- data/lib/bundler/man/bundle-remove.1 +4 -14
- data/lib/bundler/man/bundle-show.1 +3 -10
- data/lib/bundler/man/bundle-update.1 +19 -138
- data/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle-viz.1 +6 -15
- data/lib/bundler/man/bundle-viz.1.ronn +2 -0
- data/lib/bundler/man/bundle.1 +17 -51
- data/lib/bundler/man/bundle.1.ronn +12 -7
- data/lib/bundler/man/gemfile.5 +130 -346
- data/lib/bundler/man/gemfile.5.ronn +121 -86
- data/lib/bundler/man/index.txt +4 -0
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +1 -2
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/mirror.rb +8 -10
- data/lib/bundler/plugin/api/source.rb +9 -13
- data/lib/bundler/plugin/index.rb +13 -5
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +0 -8
- data/lib/bundler/plugin/installer.rb +42 -19
- data/lib/bundler/plugin/source_list.rb +4 -4
- data/lib/bundler/plugin.rb +16 -7
- data/lib/bundler/process_lock.rb +1 -1
- data/lib/bundler/remote_specification.rb +11 -5
- data/lib/bundler/resolver/base.rb +111 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +81 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +53 -66
- data/lib/bundler/resolver.rb +419 -307
- data/lib/bundler/retry.rb +1 -1
- data/lib/bundler/ruby_dsl.rb +42 -7
- data/lib/bundler/ruby_version.rb +16 -22
- data/lib/bundler/rubygems_ext.rb +250 -64
- data/lib/bundler/rubygems_gem_installer.rb +90 -64
- data/lib/bundler/rubygems_integration.rb +81 -190
- data/lib/bundler/runtime.rb +8 -13
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +206 -0
- data/lib/bundler/settings.rb +139 -57
- data/lib/bundler/setup.rb +13 -1
- data/lib/bundler/shared_helpers.rb +67 -36
- data/lib/bundler/source/git/git_proxy.rb +285 -82
- data/lib/bundler/source/git.rb +81 -41
- data/lib/bundler/source/metadata.rb +17 -16
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +13 -25
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +164 -234
- data/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/lib/bundler/source.rb +7 -6
- data/lib/bundler/source_list.rb +40 -32
- data/lib/bundler/source_map.rb +15 -2
- data/lib/bundler/spec_set.rb +156 -46
- data/lib/bundler/stub_specification.rb +18 -5
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +7 -12
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
- data/lib/bundler/templates/newgem/README.md.tt +7 -11
- data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
- data/lib/bundler/templates/newgem/bin/console.tt +0 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -3
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +25 -17
- data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +38 -15
- data/lib/bundler/ui/silent.rb +21 -5
- data/lib/bundler/uri_credentials_filter.rb +2 -2
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1340 -410
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +57 -57
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +12 -14
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
- data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
- data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +63 -7
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +48 -154
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +316 -207
- data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +33 -13
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +105 -47
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +0 -36
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
- data/lib/bundler/vendored_uri.rb +18 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +7 -9
- data/lib/bundler/yaml_serializer.rb +21 -12
- data/lib/bundler.rb +114 -121
- metadata +87 -41
- data/lib/bundler/dep_proxy.rb +0 -55
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -22
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/version_ranges.rb +0 -122
@@ -3,7 +3,6 @@
|
|
3
3
|
# = uri/common.rb
|
4
4
|
#
|
5
5
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
|
-
# Revision:: $Id$
|
7
6
|
# License::
|
8
7
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
9
8
|
#
|
@@ -14,9 +13,12 @@ require_relative "rfc2396_parser"
|
|
14
13
|
require_relative "rfc3986_parser"
|
15
14
|
|
16
15
|
module Bundler::URI
|
16
|
+
include RFC2396_REGEXP
|
17
|
+
|
17
18
|
REGEXP = RFC2396_REGEXP
|
18
19
|
Parser = RFC2396_Parser
|
19
20
|
RFC3986_PARSER = RFC3986_Parser.new
|
21
|
+
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
|
20
22
|
|
21
23
|
# Bundler::URI::Parser.new
|
22
24
|
DEFAULT_PARSER = Parser.new
|
@@ -28,6 +30,7 @@ module Bundler::URI
|
|
28
30
|
DEFAULT_PARSER.regexp.each_pair do |sym, str|
|
29
31
|
const_set(sym, str)
|
30
32
|
end
|
33
|
+
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
|
31
34
|
|
32
35
|
module Util # :nodoc:
|
33
36
|
def make_components_hash(klass, array_hash)
|
@@ -61,88 +64,72 @@ module Bundler::URI
|
|
61
64
|
module_function :make_components_hash
|
62
65
|
end
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# == Synopsis
|
68
|
-
#
|
69
|
-
# Bundler::URI.escape(str [, unsafe])
|
70
|
-
#
|
71
|
-
# == Args
|
72
|
-
#
|
73
|
-
# +str+::
|
74
|
-
# String to replaces in.
|
75
|
-
# +unsafe+::
|
76
|
-
# Regexp that matches all symbols that must be replaced with codes.
|
77
|
-
# By default uses <tt>UNSAFE</tt>.
|
78
|
-
# When this argument is a String, it represents a character set.
|
79
|
-
#
|
80
|
-
# == Description
|
81
|
-
#
|
82
|
-
# Escapes the string, replacing all unsafe characters with codes.
|
83
|
-
#
|
84
|
-
# This method is obsolete and should not be used. Instead, use
|
85
|
-
# CGI.escape, Bundler::URI.encode_www_form or Bundler::URI.encode_www_form_component
|
86
|
-
# depending on your specific use case.
|
87
|
-
#
|
88
|
-
# == Usage
|
89
|
-
#
|
90
|
-
# require 'bundler/vendor/uri/lib/uri'
|
91
|
-
#
|
92
|
-
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
93
|
-
# # => "http://example.com/?a=%09%0D"
|
94
|
-
#
|
95
|
-
# Bundler::URI.unescape(enc_uri)
|
96
|
-
# # => "http://example.com/?a=\t\r"
|
97
|
-
#
|
98
|
-
# Bundler::URI.escape("@?@!", "!?")
|
99
|
-
# # => "@%3F@%21"
|
100
|
-
#
|
101
|
-
def escape(*arg)
|
102
|
-
warn "Bundler::URI.escape is obsolete", uplevel: 1
|
103
|
-
DEFAULT_PARSER.escape(*arg)
|
104
|
-
end
|
105
|
-
alias encode escape
|
106
|
-
#
|
107
|
-
# == Synopsis
|
108
|
-
#
|
109
|
-
# Bundler::URI.unescape(str)
|
110
|
-
#
|
111
|
-
# == Args
|
112
|
-
#
|
113
|
-
# +str+::
|
114
|
-
# String to unescape.
|
115
|
-
#
|
116
|
-
# == Description
|
117
|
-
#
|
118
|
-
# This method is obsolete and should not be used. Instead, use
|
119
|
-
# CGI.unescape, Bundler::URI.decode_www_form or Bundler::URI.decode_www_form_component
|
120
|
-
# depending on your specific use case.
|
121
|
-
#
|
122
|
-
# == Usage
|
123
|
-
#
|
124
|
-
# require 'bundler/vendor/uri/lib/uri'
|
125
|
-
#
|
126
|
-
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
127
|
-
# # => "http://example.com/?a=%09%0D"
|
128
|
-
#
|
129
|
-
# Bundler::URI.unescape(enc_uri)
|
130
|
-
# # => "http://example.com/?a=\t\r"
|
131
|
-
#
|
132
|
-
def unescape(*arg)
|
133
|
-
warn "Bundler::URI.unescape is obsolete", uplevel: 1
|
134
|
-
DEFAULT_PARSER.unescape(*arg)
|
135
|
-
end
|
136
|
-
alias decode unescape
|
137
|
-
end # module Escape
|
67
|
+
module Schemes
|
68
|
+
end
|
69
|
+
private_constant :Schemes
|
138
70
|
|
139
|
-
|
140
|
-
|
71
|
+
# Registers the given +klass+ as the class to be instantiated
|
72
|
+
# when parsing a \Bundler::URI with the given +scheme+:
|
73
|
+
#
|
74
|
+
# Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
|
75
|
+
# Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
|
76
|
+
#
|
77
|
+
# Note that after calling String#upcase on +scheme+, it must be a valid
|
78
|
+
# constant name.
|
79
|
+
def self.register_scheme(scheme, klass)
|
80
|
+
Schemes.const_set(scheme.to_s.upcase, klass)
|
81
|
+
end
|
141
82
|
|
142
|
-
|
143
|
-
#
|
83
|
+
# Returns a hash of the defined schemes:
|
84
|
+
#
|
85
|
+
# Bundler::URI.scheme_list
|
86
|
+
# # =>
|
87
|
+
# {"MAILTO"=>Bundler::URI::MailTo,
|
88
|
+
# "LDAPS"=>Bundler::URI::LDAPS,
|
89
|
+
# "WS"=>Bundler::URI::WS,
|
90
|
+
# "HTTP"=>Bundler::URI::HTTP,
|
91
|
+
# "HTTPS"=>Bundler::URI::HTTPS,
|
92
|
+
# "LDAP"=>Bundler::URI::LDAP,
|
93
|
+
# "FILE"=>Bundler::URI::File,
|
94
|
+
# "FTP"=>Bundler::URI::FTP}
|
95
|
+
#
|
96
|
+
# Related: Bundler::URI.register_scheme.
|
144
97
|
def self.scheme_list
|
145
|
-
|
98
|
+
Schemes.constants.map { |name|
|
99
|
+
[name.to_s.upcase, Schemes.const_get(name)]
|
100
|
+
}.to_h
|
101
|
+
end
|
102
|
+
|
103
|
+
INITIAL_SCHEMES = scheme_list
|
104
|
+
private_constant :INITIAL_SCHEMES
|
105
|
+
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
|
106
|
+
|
107
|
+
# Returns a new object constructed from the given +scheme+, +arguments+,
|
108
|
+
# and +default+:
|
109
|
+
#
|
110
|
+
# - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
|
111
|
+
# - The object is initialized by calling the class initializer
|
112
|
+
# using +scheme+ and +arguments+.
|
113
|
+
# See Bundler::URI::Generic.new.
|
114
|
+
#
|
115
|
+
# Examples:
|
116
|
+
#
|
117
|
+
# values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
|
118
|
+
# Bundler::URI.for('https', *values)
|
119
|
+
# # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
120
|
+
# Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
|
121
|
+
# # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
122
|
+
#
|
123
|
+
def self.for(scheme, *arguments, default: Generic)
|
124
|
+
const_name = scheme.to_s.upcase
|
125
|
+
|
126
|
+
uri_class = INITIAL_SCHEMES[const_name]
|
127
|
+
uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
|
128
|
+
Schemes.const_get(const_name, false)
|
129
|
+
end
|
130
|
+
uri_class ||= default
|
131
|
+
|
132
|
+
return uri_class.new(scheme, *arguments)
|
146
133
|
end
|
147
134
|
|
148
135
|
#
|
@@ -162,95 +149,49 @@ module Bundler::URI
|
|
162
149
|
#
|
163
150
|
class BadURIError < Error; end
|
164
151
|
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
# * Port
|
183
|
-
# * Registry
|
184
|
-
# * Path
|
185
|
-
# * Opaque
|
186
|
-
# * Query
|
187
|
-
# * Fragment
|
188
|
-
#
|
189
|
-
# == Usage
|
190
|
-
#
|
191
|
-
# require 'bundler/vendor/uri/lib/uri'
|
192
|
-
#
|
193
|
-
# Bundler::URI.split("http://www.ruby-lang.org/")
|
194
|
-
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
|
152
|
+
# Returns a 9-element array representing the parts of the \Bundler::URI
|
153
|
+
# formed from the string +uri+;
|
154
|
+
# each array element is a string or +nil+:
|
155
|
+
#
|
156
|
+
# names = %w[scheme userinfo host port registry path opaque query fragment]
|
157
|
+
# values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
158
|
+
# names.zip(values)
|
159
|
+
# # =>
|
160
|
+
# [["scheme", "https"],
|
161
|
+
# ["userinfo", "john.doe"],
|
162
|
+
# ["host", "www.example.com"],
|
163
|
+
# ["port", "123"],
|
164
|
+
# ["registry", nil],
|
165
|
+
# ["path", "/forum/questions/"],
|
166
|
+
# ["opaque", nil],
|
167
|
+
# ["query", "tag=networking&order=newest"],
|
168
|
+
# ["fragment", "top"]]
|
195
169
|
#
|
196
170
|
def self.split(uri)
|
197
171
|
RFC3986_PARSER.split(uri)
|
198
172
|
end
|
199
173
|
|
174
|
+
# Returns a new \Bundler::URI object constructed from the given string +uri+:
|
200
175
|
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
# Bundler::URI
|
204
|
-
#
|
205
|
-
# == Args
|
206
|
-
#
|
207
|
-
# +uri_str+::
|
208
|
-
# String with Bundler::URI.
|
209
|
-
#
|
210
|
-
# == Description
|
211
|
-
#
|
212
|
-
# Creates one of the Bundler::URI's subclasses instance from the string.
|
176
|
+
# Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
177
|
+
# # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
178
|
+
# Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
179
|
+
# # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
213
180
|
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
# Bundler::URI::InvalidURIError::
|
217
|
-
# Raised if Bundler::URI given is not a correct one.
|
218
|
-
#
|
219
|
-
# == Usage
|
220
|
-
#
|
221
|
-
# require 'bundler/vendor/uri/lib/uri'
|
222
|
-
#
|
223
|
-
# uri = Bundler::URI.parse("http://www.ruby-lang.org/")
|
224
|
-
# # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
|
225
|
-
# uri.scheme
|
226
|
-
# # => "http"
|
227
|
-
# uri.host
|
228
|
-
# # => "www.ruby-lang.org"
|
229
|
-
#
|
230
|
-
# It's recommended to first ::escape the provided +uri_str+ if there are any
|
231
|
-
# invalid Bundler::URI characters.
|
181
|
+
# It's recommended to first ::escape string +uri+
|
182
|
+
# if it may contain invalid Bundler::URI characters.
|
232
183
|
#
|
233
184
|
def self.parse(uri)
|
234
185
|
RFC3986_PARSER.parse(uri)
|
235
186
|
end
|
236
187
|
|
188
|
+
# Merges the given Bundler::URI strings +str+
|
189
|
+
# per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
|
237
190
|
#
|
238
|
-
#
|
191
|
+
# Each string in +str+ is converted to an
|
192
|
+
# {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
|
239
193
|
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
# == Args
|
243
|
-
#
|
244
|
-
# +str+::
|
245
|
-
# String(s) to work with, will be converted to RFC3986 URIs before merging.
|
246
|
-
#
|
247
|
-
# == Description
|
248
|
-
#
|
249
|
-
# Joins URIs.
|
250
|
-
#
|
251
|
-
# == Usage
|
252
|
-
#
|
253
|
-
# require 'bundler/vendor/uri/lib/uri'
|
194
|
+
# Examples:
|
254
195
|
#
|
255
196
|
# Bundler::URI.join("http://example.com/","main.rbx")
|
256
197
|
# # => #<Bundler::URI::HTTP http://example.com/main.rbx>
|
@@ -295,7 +236,7 @@ module Bundler::URI
|
|
295
236
|
# Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
|
296
237
|
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
|
297
238
|
#
|
298
|
-
def self.extract(str, schemes = nil, &block)
|
239
|
+
def self.extract(str, schemes = nil, &block) # :nodoc:
|
299
240
|
warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
|
300
241
|
DEFAULT_PARSER.extract(str, schemes, &block)
|
301
242
|
end
|
@@ -315,7 +256,7 @@ module Bundler::URI
|
|
315
256
|
#
|
316
257
|
# Returns a Regexp object which matches to Bundler::URI-like strings.
|
317
258
|
# The Regexp object returned by this method includes arbitrary
|
318
|
-
# number of capture group (parentheses). Never rely on
|
259
|
+
# number of capture group (parentheses). Never rely on its number.
|
319
260
|
#
|
320
261
|
# == Usage
|
321
262
|
#
|
@@ -332,7 +273,7 @@ module Bundler::URI
|
|
332
273
|
# p $&
|
333
274
|
# end
|
334
275
|
#
|
335
|
-
def self.regexp(schemes = nil)
|
276
|
+
def self.regexp(schemes = nil)# :nodoc:
|
336
277
|
warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
|
337
278
|
DEFAULT_PARSER.make_regexp(schemes)
|
338
279
|
end
|
@@ -341,6 +282,7 @@ module Bundler::URI
|
|
341
282
|
256.times do |i|
|
342
283
|
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
|
343
284
|
end
|
285
|
+
TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
|
344
286
|
TBLENCWWWCOMP_[' '] = '+'
|
345
287
|
TBLENCWWWCOMP_.freeze
|
346
288
|
TBLDECWWWCOMP_ = {} # :nodoc:
|
@@ -354,18 +296,91 @@ module Bundler::URI
|
|
354
296
|
TBLDECWWWCOMP_['+'] = ' '
|
355
297
|
TBLDECWWWCOMP_.freeze
|
356
298
|
|
357
|
-
#
|
299
|
+
# Returns a URL-encoded string derived from the given string +str+.
|
300
|
+
#
|
301
|
+
# The returned string:
|
302
|
+
#
|
303
|
+
# - Preserves:
|
304
|
+
#
|
305
|
+
# - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
|
306
|
+
# - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
|
307
|
+
# and <tt>'0'..'9'</tt>.
|
308
|
+
#
|
309
|
+
# Example:
|
358
310
|
#
|
359
|
-
#
|
360
|
-
#
|
311
|
+
# Bundler::URI.encode_www_form_component('*.-_azAZ09')
|
312
|
+
# # => "*.-_azAZ09"
|
361
313
|
#
|
362
|
-
#
|
314
|
+
# - Converts:
|
363
315
|
#
|
364
|
-
#
|
365
|
-
#
|
316
|
+
# - Character <tt>' '</tt> to character <tt>'+'</tt>.
|
317
|
+
# - Any other character to "percent notation";
|
318
|
+
# the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
|
366
319
|
#
|
367
|
-
#
|
320
|
+
# Example:
|
321
|
+
#
|
322
|
+
# Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
|
323
|
+
# # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
|
324
|
+
#
|
325
|
+
# Encoding:
|
326
|
+
#
|
327
|
+
# - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
|
328
|
+
# - Otherwise +str+ is converted first to Encoding::UTF_8
|
329
|
+
# (with suitable character replacements),
|
330
|
+
# and then to encoding +enc+.
|
331
|
+
#
|
332
|
+
# In either case, the returned string has forced encoding Encoding::US_ASCII.
|
333
|
+
#
|
334
|
+
# Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
|
368
335
|
def self.encode_www_form_component(str, enc=nil)
|
336
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
|
337
|
+
end
|
338
|
+
|
339
|
+
# Returns a string decoded from the given \URL-encoded string +str+.
|
340
|
+
#
|
341
|
+
# The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
|
342
|
+
# then decoded (as below), and finally force-encoded to the given encoding +enc+.
|
343
|
+
#
|
344
|
+
# The returned string:
|
345
|
+
#
|
346
|
+
# - Preserves:
|
347
|
+
#
|
348
|
+
# - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
|
349
|
+
# - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
|
350
|
+
# and <tt>'0'..'9'</tt>.
|
351
|
+
#
|
352
|
+
# Example:
|
353
|
+
#
|
354
|
+
# Bundler::URI.decode_www_form_component('*.-_azAZ09')
|
355
|
+
# # => "*.-_azAZ09"
|
356
|
+
#
|
357
|
+
# - Converts:
|
358
|
+
#
|
359
|
+
# - Character <tt>'+'</tt> to character <tt>' '</tt>.
|
360
|
+
# - Each "percent notation" to an ASCII character.
|
361
|
+
#
|
362
|
+
# Example:
|
363
|
+
#
|
364
|
+
# Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
|
365
|
+
# # => "Here are some punctuation characters: ,;?:"
|
366
|
+
#
|
367
|
+
# Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
|
368
|
+
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
369
|
+
_decode_uri_component(/\+|%\h\h/, str, enc)
|
370
|
+
end
|
371
|
+
|
372
|
+
# Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
|
373
|
+
# is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
|
374
|
+
def self.encode_uri_component(str, enc=nil)
|
375
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
|
376
|
+
end
|
377
|
+
|
378
|
+
# Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
|
379
|
+
def self.decode_uri_component(str, enc=Encoding::UTF_8)
|
380
|
+
_decode_uri_component(/%\h\h/, str, enc)
|
381
|
+
end
|
382
|
+
|
383
|
+
def self._encode_uri_component(regexp, table, str, enc)
|
369
384
|
str = str.to_s.dup
|
370
385
|
if str.encoding != Encoding::ASCII_8BIT
|
371
386
|
if enc && enc != Encoding::ASCII_8BIT
|
@@ -374,47 +389,115 @@ module Bundler::URI
|
|
374
389
|
end
|
375
390
|
str.force_encoding(Encoding::ASCII_8BIT)
|
376
391
|
end
|
377
|
-
str.gsub!(
|
392
|
+
str.gsub!(regexp, table)
|
378
393
|
str.force_encoding(Encoding::US_ASCII)
|
379
394
|
end
|
395
|
+
private_class_method :_encode_uri_component
|
380
396
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
#
|
385
|
-
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
386
|
-
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
387
|
-
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
|
388
|
-
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
|
397
|
+
def self._decode_uri_component(regexp, str, enc)
|
398
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
|
399
|
+
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
|
389
400
|
end
|
401
|
+
private_class_method :_decode_uri_component
|
390
402
|
|
391
|
-
#
|
403
|
+
# Returns a URL-encoded string derived from the given
|
404
|
+
# {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
|
405
|
+
# +enum+.
|
406
|
+
#
|
407
|
+
# The result is suitable for use as form data
|
408
|
+
# for an \HTTP request whose <tt>Content-Type</tt> is
|
409
|
+
# <tt>'application/x-www-form-urlencoded'</tt>.
|
410
|
+
#
|
411
|
+
# The returned string consists of the elements of +enum+,
|
412
|
+
# each converted to one or more URL-encoded strings,
|
413
|
+
# and all joined with character <tt>'&'</tt>.
|
414
|
+
#
|
415
|
+
# Simple examples:
|
392
416
|
#
|
393
|
-
#
|
394
|
-
#
|
417
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
|
418
|
+
# # => "foo=0&bar=1&baz=2"
|
419
|
+
# Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
420
|
+
# # => "foo=0&bar=1&baz=2"
|
395
421
|
#
|
396
|
-
#
|
422
|
+
# The returned string is formed using method Bundler::URI.encode_www_form_component,
|
423
|
+
# which converts certain characters:
|
397
424
|
#
|
398
|
-
#
|
399
|
-
#
|
400
|
-
# encoding or mixed encoding data. (Strings which are encoded in an HTML5
|
401
|
-
# ASCII incompatible encoding are converted to UTF-8.)
|
425
|
+
# Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
|
426
|
+
# # => "f%23o=%2F&b-r=%24&b+z=%40"
|
402
427
|
#
|
403
|
-
#
|
404
|
-
# multipart/form-data.
|
428
|
+
# When +enum+ is Array-like, each element +ele+ is converted to a field:
|
405
429
|
#
|
406
|
-
#
|
430
|
+
# - If +ele+ is an array of two or more elements,
|
431
|
+
# the field is formed from its first two elements
|
432
|
+
# (and any additional elements are ignored):
|
407
433
|
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
434
|
+
# name = Bundler::URI.encode_www_form_component(ele[0], enc)
|
435
|
+
# value = Bundler::URI.encode_www_form_component(ele[1], enc)
|
436
|
+
# "#{name}=#{value}"
|
437
|
+
#
|
438
|
+
# Examples:
|
439
|
+
#
|
440
|
+
# Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
|
441
|
+
# # => "foo=bar&baz=bat"
|
442
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
|
443
|
+
# # => "foo=0&bar=baz"
|
444
|
+
#
|
445
|
+
# - If +ele+ is an array of one element,
|
446
|
+
# the field is formed from <tt>ele[0]</tt>:
|
447
|
+
#
|
448
|
+
# Bundler::URI.encode_www_form_component(ele[0])
|
449
|
+
#
|
450
|
+
# Example:
|
451
|
+
#
|
452
|
+
# Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
|
453
|
+
# # => "foo&bar&0"
|
454
|
+
#
|
455
|
+
# - Otherwise the field is formed from +ele+:
|
456
|
+
#
|
457
|
+
# Bundler::URI.encode_www_form_component(ele)
|
458
|
+
#
|
459
|
+
# Example:
|
460
|
+
#
|
461
|
+
# Bundler::URI.encode_www_form(['foo', :bar, 0])
|
462
|
+
# # => "foo&bar&0"
|
463
|
+
#
|
464
|
+
# The elements of an Array-like +enum+ may be mixture:
|
465
|
+
#
|
466
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
|
467
|
+
# # => "foo=0&bar=1&baz&bat"
|
468
|
+
#
|
469
|
+
# When +enum+ is Hash-like,
|
470
|
+
# each +key+/+value+ pair is converted to one or more fields:
|
471
|
+
#
|
472
|
+
# - If +value+ is
|
473
|
+
# {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects],
|
474
|
+
# each element +ele+ in +value+ is paired with +key+ to form a field:
|
475
|
+
#
|
476
|
+
# name = Bundler::URI.encode_www_form_component(key, enc)
|
477
|
+
# value = Bundler::URI.encode_www_form_component(ele, enc)
|
478
|
+
# "#{name}=#{value}"
|
479
|
+
#
|
480
|
+
# Example:
|
481
|
+
#
|
482
|
+
# Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
|
483
|
+
# # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
|
484
|
+
#
|
485
|
+
# - Otherwise, +key+ and +value+ are paired to form a field:
|
486
|
+
#
|
487
|
+
# name = Bundler::URI.encode_www_form_component(key, enc)
|
488
|
+
# value = Bundler::URI.encode_www_form_component(value, enc)
|
489
|
+
# "#{name}=#{value}"
|
490
|
+
#
|
491
|
+
# Example:
|
492
|
+
#
|
493
|
+
# Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
494
|
+
# # => "foo=0&bar=1&baz=2"
|
495
|
+
#
|
496
|
+
# The elements of a Hash-like +enum+ may be mixture:
|
497
|
+
#
|
498
|
+
# Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
|
499
|
+
# # => "foo=0&foo=1&bar=2"
|
416
500
|
#
|
417
|
-
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
418
501
|
def self.encode_www_form(enum, enc=nil)
|
419
502
|
enum.map do |k,v|
|
420
503
|
if v.nil?
|
@@ -435,22 +518,39 @@ module Bundler::URI
|
|
435
518
|
end.join('&')
|
436
519
|
end
|
437
520
|
|
438
|
-
#
|
521
|
+
# Returns name/value pairs derived from the given string +str+,
|
522
|
+
# which must be an ASCII string.
|
523
|
+
#
|
524
|
+
# The method may be used to decode the body of Net::HTTPResponse object +res+
|
525
|
+
# for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
|
439
526
|
#
|
440
|
-
#
|
441
|
-
#
|
527
|
+
# The returned data is an array of 2-element subarrays;
|
528
|
+
# each subarray is a name/value pair (both are strings).
|
529
|
+
# Each returned string has encoding +enc+,
|
530
|
+
# and has had invalid characters removed via
|
531
|
+
# {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub].
|
442
532
|
#
|
443
|
-
#
|
444
|
-
# so this supports only &-separator, and doesn't support ;-separator.
|
533
|
+
# A simple example:
|
445
534
|
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
535
|
+
# Bundler::URI.decode_www_form('foo=0&bar=1&baz')
|
536
|
+
# # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
|
537
|
+
#
|
538
|
+
# The returned strings have certain conversions,
|
539
|
+
# similar to those performed in Bundler::URI.decode_www_form_component:
|
540
|
+
#
|
541
|
+
# Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
|
542
|
+
# # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
|
543
|
+
#
|
544
|
+
# The given string may contain consecutive separators:
|
545
|
+
#
|
546
|
+
# Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
|
547
|
+
# # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
|
548
|
+
#
|
549
|
+
# A different separator may be specified:
|
550
|
+
#
|
551
|
+
# Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
|
552
|
+
# # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
|
452
553
|
#
|
453
|
-
# See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
|
454
554
|
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
|
455
555
|
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
|
456
556
|
ary = []
|
@@ -716,6 +816,7 @@ module Bundler::URI
|
|
716
816
|
"utf-16"=>"utf-16le",
|
717
817
|
"utf-16le"=>"utf-16le",
|
718
818
|
} # :nodoc:
|
819
|
+
Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
|
719
820
|
|
720
821
|
# :nodoc:
|
721
822
|
# return encoding or nil
|
@@ -728,7 +829,15 @@ end # module Bundler::URI
|
|
728
829
|
module Bundler
|
729
830
|
|
730
831
|
#
|
731
|
-
# Returns
|
832
|
+
# Returns a \Bundler::URI object derived from the given +uri+,
|
833
|
+
# which may be a \Bundler::URI string or an existing \Bundler::URI object:
|
834
|
+
#
|
835
|
+
# # Returns a new Bundler::URI.
|
836
|
+
# uri = Bundler::URI('http://github.com/ruby/ruby')
|
837
|
+
# # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
|
838
|
+
# # Returns the given Bundler::URI.
|
839
|
+
# Bundler::URI(uri)
|
840
|
+
# # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
|
732
841
|
#
|
733
842
|
def URI(uri)
|
734
843
|
if uri.is_a?(Bundler::URI::Generic)
|
@@ -33,6 +33,9 @@ module Bundler::URI
|
|
33
33
|
# If an Array is used, the components must be passed in the
|
34
34
|
# order <code>[host, path]</code>.
|
35
35
|
#
|
36
|
+
# A path from e.g. the File class should be escaped before
|
37
|
+
# being passed.
|
38
|
+
#
|
36
39
|
# Examples:
|
37
40
|
#
|
38
41
|
# require 'bundler/vendor/uri/lib/uri'
|
@@ -44,6 +47,9 @@ module Bundler::URI
|
|
44
47
|
# :path => '/ruby/src'})
|
45
48
|
# uri2.to_s # => "file://host.example.com/ruby/src"
|
46
49
|
#
|
50
|
+
# uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')})
|
51
|
+
# uri3.to_s # => "file:///path/my%20file.txt"
|
52
|
+
#
|
47
53
|
def self.build(args)
|
48
54
|
tmp = Util::make_components_hash(self, args)
|
49
55
|
super(tmp)
|
@@ -90,5 +96,5 @@ module Bundler::URI
|
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
93
|
-
|
99
|
+
register_scheme 'FILE', File
|
94
100
|
end
|