Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit ac8b5d1

Browse files
committed
Fixing usages of URI.encode so nicinfo is compatible with ruby 3.0+.
1 parent b7cb3fd commit ac8b5d1

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

lib/nicinfo/constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
module NicInfo
2020

21-
VERSION = "1.5.0"
21+
VERSION = "1.5.1"
2222
VERSION_LABEL = "NicInfo v." + VERSION
2323
COPYRIGHT = "Copyright (c) 2011-2017 American Registry for Internet Numbers (ARIN)"
2424
CONFIG_VERSION = 4

lib/nicinfo/nicinfo_main.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ def get url, try, expect_rdap = true
319319
if data == nil
320320

321321
@config.logger.trace("Issuing GET for " + url)
322-
uri = URI.parse( URI::encode( url ) )
322+
p = URI::Parser.new
323+
uri = URI.parse( p.escape( url ) )
323324
req = Net::HTTP::Get.new(uri.request_uri)
324325
req["User-Agent"] = NicInfo::VERSION_LABEL
325326
req["Accept"] = NicInfo::RDAP_CONTENT_TYPE + ", " + NicInfo::JSON_CONTENT_TYPE
@@ -376,7 +377,8 @@ def get url, try, expect_rdap = true
376377
def get_file_via_http url, file_name, try
377378

378379
@config.logger.trace("Downloading " + url + " to " + file_name )
379-
uri = URI.parse( URI::encode( url ) )
380+
p = URI::Parser.new
381+
uri = URI.parse( p.escape( url ) )
380382
req = Net::HTTP::Get.new(uri.request_uri)
381383
req["User-Agent"] = NicInfo::VERSION_LABEL
382384
req["Accept"] = NicInfo::JSON_CONTENT_TYPE
@@ -937,7 +939,7 @@ def guess_query_value_type(args)
937939

938940
# Creates a query type
939941
def create_resource_url(args, queryType)
940-
942+
p = URI::Parser.new
941943
path = ""
942944
case queryType
943945
when QueryType::BY_IP4_ADDR
@@ -959,15 +961,15 @@ def create_resource_url(args, queryType)
959961
path = tree.find_rest_ref(args[0])
960962
raise ArgumentError.new("Unable to find result for " + args[0]) unless path
961963
when QueryType::BY_ENTITY_HANDLE
962-
path << "entity/" << URI.escape( args[ 0 ] )
964+
path << "entity/" << p.escape( args[ 0 ] )
963965
when QueryType::SRCH_ENTITY_BY_NAME
964966
case args.length
965967
when 1
966-
path << "entities?fn=" << URI.escape( args[ 0 ] )
968+
path << "entities?fn=" << p.escape( args[ 0 ] )
967969
when 2
968-
path << "entities?fn=" << URI.escape( args[ 0 ] + " " + args[ 1 ] )
970+
path << "entities?fn=" << p.escape( args[ 0 ] + " " + args[ 1 ] )
969971
when 3
970-
path << "entities?fn=" << URI.escape( args[ 0 ] + " " + args[ 1 ] + " " + args[ 2 ] )
972+
path << "entities?fn=" << p.escape( args[ 0 ] + " " + args[ 1 ] + " " + args[ 2 ] )
971973
end
972974
when QueryType::SRCH_DOMAIN_BY_NAME
973975
path << "domains?name=" << args[ 0 ]

lib/nicinfo/utils.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
module NicInfo
2121

2222
def NicInfo.make_safe( url )
23-
safe = URI.escape( url )
24-
safe = URI.escape( safe, "!*'();:@&=+$,/?#[]" )
23+
p = URI::Parser.new
24+
safe = p.escape( url )
25+
safe = p.escape( safe, "!*'();:@&=+$,/?#[]" )
2526
return safe
2627
end
2728

nicinfo.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
99
s.date = Time.now.strftime( "%Y-%m-%d" )
1010
s.summary = "RDAP Client"
1111
s.description = "A command-line RDAP client."
12-
s.authors = ["Andrew Newton"]
13-
s.email = 'andy@arin.net'
12+
s.authors = ["Andrew Newton","Garth Dubin"]
13+
s.email = 'gdubin@arin.net'
1414
s.files = Dir["lib/**/*"].entries
1515
s.homepage = 'https://github.com/arinlabs/nicinfo'
1616
s.license = 'ISC'

0 commit comments

Comments
 (0)