Skip to content

Commit

Permalink
Merge pull request #300 from chef/lcg/uri-encode
Browse files Browse the repository at this point in the history
remove deprecation warnings for ruby 2.7
  • Loading branch information
lamont-granquist authored Feb 19, 2020
2 parents 85b50f9 + 00bf37b commit d6054d2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .expeditor/run_linux_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ else
fi

echo "+++ bundle exec task"
bundle exec $1
bundle exec $@
24 changes: 3 additions & 21 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,10 @@ expeditor:

steps:

- label: run-lint-and-specs-ruby-2.4
command:
- apt-get update
- .expeditor/run_linux_tests.sh rake spec style
expeditor:
executor:
docker:
image: ruby:2.4-buster

- label: run-lint-and-specs-ruby-2.5
command:
- apt-get update
- .expeditor/run_linux_tests.sh rake spec style
expeditor:
executor:
docker:
image: ruby:2.5-buster

- label: run-lint-and-specs-ruby-2.6
command:
- apt-get update
- .expeditor/run_linux_tests.sh rake spec style
- .expeditor/run_linux_tests.sh rake spec pedant style
expeditor:
executor:
docker:
Expand All @@ -36,7 +18,7 @@ steps:
- label: run-lint-and-specs-ruby-2.7
command:
- apt-get update
- .expeditor/run_linux_tests.sh rake spec style
- .expeditor/run_linux_tests.sh rake spec pedant style
expeditor:
executor:
docker:
Expand All @@ -45,7 +27,7 @@ steps:
- label: run-specs-windows
command:
- bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake spec
- bundle exec rake pedant style
expeditor:
executor:
docker:
Expand Down
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions chef-zero.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions lib/chef_zero/rest_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def accepts?(request, category, type)

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
Expand Down Expand Up @@ -284,7 +284,7 @@ def build_uri(base_uri, rest_path)
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)
Expand Down Expand Up @@ -324,5 +324,9 @@ def policy_name_invalid?(name)
name.size > 255 ||
name =~ /[+ !]/
end

def self.rfc2396_parser
@parser ||= URI::RFC2396_Parser.new
end
end
end
8 changes: 6 additions & 2 deletions lib/chef_zero/rest_request.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -61,7 +61,7 @@ def query_params
@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
Expand All @@ -80,5 +80,9 @@ def to_s
end
result
end

def self.rfc2396_parser
@parser ||= URI::RFC2396_Parser.new
end
end
end

0 comments on commit d6054d2

Please sign in to comment.