Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.1
3.0.4
2 changes: 1 addition & 1 deletion fog-aliyun.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'mime-types', '~> 2.6', '>= 2.6.2'
spec.add_development_dependency 'mime-types', '~> 3.4'
spec.add_development_dependency 'pry-nav'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
Expand Down
10 changes: 5 additions & 5 deletions lib/fog/aliyun/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def VPCrequest(params)
# operation compute-- default URL
def defaultAliyunUri(action, sigNonce, time)
parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
urlTimeFormat = URI.encode(parTimeFormat, ':')
urlTimeFormat = URI.encode_www_form_component(parTimeFormat)
'?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2014-05-26&Timestamp=' + urlTimeFormat
end

Expand All @@ -370,7 +370,7 @@ def defaultAliyunQueryParameters(action, sigNonce, time)

def defaultAliyunVPCUri(action, sigNonce, time)
parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
urlTimeFormat = URI.encode(parTimeFormat, ':')
urlTimeFormat = URI.encode_www_form_component(parTimeFormat)
'?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2016-04-28&Timestamp=' + urlTimeFormat
end

Expand Down Expand Up @@ -420,18 +420,18 @@ def defalutVPCParameters(action, sigNonce, time)
# building querystrings with string concatination.
def sign(accessKeySecret, parameters)
signature = sign_without_encoding(accessKeySecret, parameters)
URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
URI.encode_www_form_component(signature)
end

def sign_without_encoding(accessKeySecret, parameters)
sortedParameters = parameters.sort
canonicalizedQueryString = ''
sortedParameters.each do |k, v|
canonicalizedQueryString += '&' + URI.encode(k, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ') + '=' + URI.encode(v, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
canonicalizedQueryString += '&' + URI.encode_www_form_component(k) + '=' + URI.encode_www_form_component(v)
end

canonicalizedQueryString[0] = ''
stringToSign = 'GET&%2F&' + URI.encode(canonicalizedQueryString, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
stringToSign = 'GET&%2F&' + URI.encode_www_form_component(canonicalizedQueryString)
key = accessKeySecret + '&'

digVer = OpenSSL::Digest.new('sha1')
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/attach_disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def attach_disk(instanceId, diskId, options = {})
if device
parameters['Device'] = device
pathUrl += '&Device='
pathUrl += URI.encode(device, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(device)
end

signature = sign(@aliyun_accesskey_secret, parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType,

parameters['DestCidrIp'] = destCidrIp
pathUrl += '&DestCidrIp='
pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(destCidrIp)
nicType ||= 'intranet'
parameters['NicType'] = nicType
pathUrl += '&NicType='
Expand All @@ -29,7 +29,7 @@ def create_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType,
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, optio

parameters['SourceCidrIp'] = sourceCidrIp
pathUrl += '&SourceCidrIp='
pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(sourceCidrIp)
nicType ||= 'intranet'
parameters['NicType'] = nicType
pathUrl += '&NicType='
Expand All @@ -29,7 +29,7 @@ def create_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, optio
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_security_group_sg_rule(securitygroup_id, source_securitygroup_id, opt
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/create_vpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_vpc(cidrBlock, options = {})

parameters['CidrBlock'] = cidrBlock
pathUrl += '&CidrBlock='
pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(cidrBlock)

name = options[:name]
desc = options[:description]
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/create_vswitch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create_vswitch(vpcId, cidrBlock, options = {})

parameters['CidrBlock'] = cidrBlock
pathUrl += '&CidrBlock='
pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(cidrBlock)

parameters['ZoneId'] = @aliyun_zone_id
pathUrl += '&ZoneId='
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType,

parameters['DestCidrIp'] = destCidrIp
pathUrl += '&DestCidrIp='
pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(destCidrIp)
nicType ||= 'intranet'
parameters['NicType'] = nicType
pathUrl += '&NicType='
Expand All @@ -29,7 +29,7 @@ def delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType,
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def delete_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def delete_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, optio

parameters['SourceCidrIp'] = sourceCidrIp
pathUrl += '&SourceCidrIp='
pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(sourceCidrIp)
nicType ||= 'intranet'
parameters['NicType'] = nicType
pathUrl += '&NicType='
Expand All @@ -29,7 +29,7 @@ def delete_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, optio
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def delete_security_group_sg_rule(securitygroup_id, source_securitygroup_id, opt
portRange ||= '-1/-1'
parameters['PortRange'] = portRange
pathUrl += '&PortRange='
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(portRange)

protocol = option[:protocol]
protocol ||= 'all'
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/detach_disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def detach_disk(instanceId, diskId, _options = {})
if device
parameters['Device'] = device
pathUrl += '&Device='
pathUrl += URI.encode(device, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(device)
end
signature = sign(@aliyun_accesskey_secret, parameters)
pathUrl += '&Signature='
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/modify_vpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def modify_vpc(vpcId, options = {})

parameters['VpcId'] = vpcId
pathUrl += '&VpcId='
pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(vpcId)
name = options[:name]
desc = options[:description]

Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/compute/modify_vswitch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def modify_switch(vSwitchId, options = {})

parameters['VSwitchId'] = vSwitchId
pathUrl += '&VSwitchId='
pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
pathUrl += URI.encode_www_form_component(vpcId)
name = options[:name]
desc = options[:description]

Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/storage/get_object_http_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_object_http_url_public(bucket_name, object_name, expires)
signature = sign('GET', expires_time, nil, resource)
'http://' + bucket_name + '.' + @host + '/' + object_name +
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
'&Signature=' + URI.encode_www_form_component(signature)
elsif acl == 'public-read' || acl == 'public-read-write'
'http://' + bucket_name + '.' + @host + '/' + object_name
else
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/aliyun/requests/storage/get_object_https_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_object_https_url_public(bucket_name, object_name, expires)
signature = sign('GET', expires_time, nil, resource)
'https://' + bucket_name + '.' + @host + '/' + object_name +
'?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
'&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
'&Signature=' + URI.encode_www_form_component(signature)
elsif acl == 'public-read' || acl == 'public-read-write'
'https://' + bucket_name + '.' + @host + '/' + object_name
else
Expand Down