diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-02-19 14:46:24 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-02-19 14:46:24 -0800 |
commit | 83431fed53ae9a738985a7415368da99461f436b (patch) | |
tree | 08e306545def3d848a1930e4ffbaaeb618a8b551 | |
parent | 85b50f9f908c1b6c51cf13b13ea9c3faaf420632 (diff) | |
download | chef-zero-83431fed53ae9a738985a7415368da99461f436b.tar.gz |
remove deprecation warnings for ruby 2.7lcg/uri-encode
we need strict compliance to rfc2396 or else pedant fails, so this is a
bit less straightforward than most of the other suggestions on how
to fix this problem.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | chef-zero.gemspec | 4 | ||||
-rw-r--r-- | lib/chef_zero/rest_base.rb | 8 | ||||
-rw-r--r-- | lib/chef_zero/rest_request.rb | 8 |
3 files changed, 14 insertions, 6 deletions
diff --git a/chef-zero.gemspec b/chef-zero.gemspec index 36406b8..64c2d24 100644 --- a/chef-zero.gemspec +++ b/chef-zero.gemspec @@ -11,10 +11,10 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/chef/chef-zero" s.license = "Apache-2.0" - s.required_ruby_version = ">= 2.4" + s.required_ruby_version = ">= 2.6" s.add_dependency "mixlib-log", ">= 2.0", "< 4.0" - s.add_dependency "hashie", ">= 2.0", "< 4.0" + s.add_dependency "hashie", ">= 2.0", "< 5.0" s.add_dependency "uuidtools", "~> 2.1" s.add_dependency "ffi-yajl", "~> 2.2" s.add_dependency "rack", "~> 2.0", ">= 2.0.6" diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb index 89c2b12..be50de2 100644 --- a/lib/chef_zero/rest_base.rb +++ b/lib/chef_zero/rest_base.rb @@ -77,7 +77,7 @@ module ChefZero def get_data(request, rest_path = nil, *options) rest_path ||= request.rest_path - rest_path = rest_path.map { |v| URI.decode(v) } + rest_path = rest_path.map { |v| self.class.rfc2396_parser.unescape(v) } begin data_store.get(rest_path, request) rescue DataStore::DataNotFoundError @@ -284,7 +284,7 @@ module ChefZero end def self.build_uri(base_uri, rest_path) - "#{base_uri}/#{rest_path.map { |v| URI.escape(v) }.join("/")}" + "#{base_uri}/#{rest_path.map { |v| rfc2396_parser.escape(v) }.join("/")}" end def populate_defaults(request, response) @@ -324,5 +324,9 @@ module ChefZero name.size > 255 || name =~ /[+ !]/ end + + def self.rfc2396_parser + @parser ||= URI::RFC2396_Parser.new + end end end diff --git a/lib/chef_zero/rest_request.rb b/lib/chef_zero/rest_request.rb index 379cc20..c260316 100644 --- a/lib/chef_zero/rest_request.rb +++ b/lib/chef_zero/rest_request.rb @@ -1,8 +1,8 @@ require "rack/request" +require "cgi" module ChefZero class RestRequest - def initialize(env, rest_base_prefix = []) @env = env @rest_base_prefix = rest_base_prefix @@ -61,7 +61,7 @@ module ChefZero @query_params ||= begin params = Rack::Request.new(env).GET params.keys.each do |key| - params[key] = URI.unescape(params[key]) + params[key] = self.class.rfc2396_parser.unescape(params[key]) end params end @@ -80,5 +80,9 @@ module ChefZero end result end + + def self.rfc2396_parser + @parser ||= URI::RFC2396_Parser.new + end end end |