11# coding: utf-8
2- require 'uri '
2+ require 'cgi '
33
44module RDF
55 ##
@@ -846,7 +846,7 @@ def parse(value)
846846 parts [ :user ] = ( user . dup . force_encoding ( Encoding ::UTF_8 ) if user )
847847 parts [ :password ] = ( password . dup . force_encoding ( Encoding ::UTF_8 ) if password )
848848 parts [ :host ] = ( host . dup . force_encoding ( Encoding ::UTF_8 ) if host )
849- parts [ :port ] = ( URI . decode ( port ) . to_i if port )
849+ parts [ :port ] = ( CGI . unescape ( port ) . to_i if port )
850850 parts [ :path ] = ( path . to_s . dup . force_encoding ( Encoding ::UTF_8 ) unless path . empty? )
851851 parts [ :query ] = ( query [ 1 ..-1 ] . dup . force_encoding ( Encoding ::UTF_8 ) if query )
852852 parts [ :fragment ] = ( fragment [ 1 ..-1 ] . dup . force_encoding ( Encoding ::UTF_8 ) if fragment )
@@ -902,7 +902,7 @@ def user=(value)
902902 # Normalized version of user
903903 # @return [String]
904904 def normalized_user
905- URI . encode ( URI . decode ( user ) , /[^#{ IUNRESERVED } |#{ SUB_DELIMS } ]/ ) if user
905+ URI . encode ( CGI . unescape ( user ) , /[^#{ IUNRESERVED } |#{ SUB_DELIMS } ]/ ) if user
906906 end
907907
908908 ##
@@ -928,7 +928,7 @@ def password=(value)
928928 # Normalized version of password
929929 # @return [String]
930930 def normalized_password
931- URI . encode ( URI . decode ( password ) , /[^#{ IUNRESERVED } |#{ SUB_DELIMS } ]/ ) if password
931+ URI . encode ( CGI . unescape ( password ) , /[^#{ IUNRESERVED } |#{ SUB_DELIMS } ]/ ) if password
932932 end
933933
934934 HOST_FROM_AUTHORITY_RE = /(?:[^@]+@)?([^:]+)(?::.*)?$/ . freeze
@@ -1180,8 +1180,8 @@ def query_values(return_type=Hash)
11801180 inject ( return_type == Hash ? { } : [ ] ) do |memo , kv |
11811181 k , v = kv . to_s . split ( '=' , 2 )
11821182 next if k . to_s . empty?
1183- k = URI . decode ( k )
1184- v = URI . decode ( v ) if v
1183+ k = CGI . unescape ( k )
1184+ v = CGI . unescape ( v ) if v
11851185 if return_type == Hash
11861186 case memo [ k ]
11871187 when nil then memo [ k ] = v
@@ -1293,7 +1293,7 @@ def self._load(data)
12931293 def normalize_segment ( value , expr , downcase = false )
12941294 if value
12951295 value = value . dup . force_encoding ( Encoding ::UTF_8 )
1296- decoded = URI . decode ( value )
1296+ decoded = CGI . unescape ( value )
12971297 decoded . downcase! if downcase
12981298 URI . encode ( decoded , /[^(?:#{ expr } )]/ )
12991299 end
0 commit comments