mdsol / mauth-client-ruby

Mauth client in Ruby
MIT License
4 stars 0 forks source link

Replace URI.escape with CGI.escape in SecurityTokenCacher to suppress "URI.escape is obsolete" warning #44

Closed ykitamura-mdsol closed 4 years ago

ykitamura-mdsol commented 4 years ago

The main change is in 30eb931.

Background

When using mauth-client with ruby 2.7, you will see this warning:

/home/travis/build/mdsol/mauth-client-ruby/lib/mauth/client/security_token_cacher.rb:27: warning: URI.escape is obsolete

https://travis-ci.org/github/mdsol/mauth-client-ruby/jobs/725788004#L322-L350

URI.escape is used only in SecurityTokenCacher to encode app_uuid when retrieving public keys from mauth:

url_encoded_app_uuid = URI.escape(app_uuid, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))

this is encoding characters not in URI::PATTERN::UNRESERVED:

URI::PATTERN::UNRESERVED
#=> "\\-_.!~*'()a-zA-Z\\d" 

CGI.escape is encoding a little more characters but it should not affect to the characters used for app_uuids:

def CGI::escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
      '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
    end.tr(' ', '+')
  end

@mdsol/team-16 @mdsol/architecture-enablement @jcarres-mdsol