paypalhttp 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 910250d5540f67f211cda11bc4c0565ec3bbc4063277198b72fddf66a9a7f8db
4
- data.tar.gz: a4574de9deaeed11f0808e0a38ad0ef5c9ad5628f9df8e6657cd1b9340279eaf
3
+ metadata.gz: e7b784f809b45daa88b7b605a078233f9d6d6389de4d22c58810ad904b1e6270
4
+ data.tar.gz: 83f24bf689519c48fb95474ffca65635b2c27eacecbabc4e4194761f88e2bceb
5
5
  SHA512:
6
- metadata.gz: 7626a3dc47b0417902ea12147a4982b0acb39b3fe1e09aeaa0748de48aa5fa1a98cdcbeeb3a1b0f96205de58b21be735033f0154970121235948895be2c05d85
7
- data.tar.gz: 0f01023ab3a9def51632d37a086e531cba7eec02007bc112273defd5d086f488f59a664e591f447332cad1e81e4de489dbc22de8ca0759869b9f4d479daf32d8
6
+ metadata.gz: f6ccd5a75ac2a07ef84c2cc55d4caacd529bd075315ec040066b1c5cdd625d5de048e11b483318eb7adc3065ceec1ac9d3aed568df4dbc1cba30bf390749cafb
7
+ data.tar.gz: cebe0720259ce83416259eed470253ba5ec716eb329216617fd79a4eabf16a576a4e5c54a9b967852c3a0009fe478a37910aacfff333bdf75b41fa2acdc1113e
@@ -1,11 +1,15 @@
1
- require 'cgi'
1
+ require 'uri'
2
2
 
3
3
  module PayPalHttp
4
4
  class FormEncoded
5
+ def initialize
6
+ @parser = URI::Parser.new()
7
+ end
8
+
5
9
  def encode(request)
6
10
  encoded_params = []
7
11
  request.body.each do |k, v|
8
- encoded_params.push("#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}")
12
+ encoded_params.push("#{@parser.escape(k.to_s)}=#{@parser.escape(v.to_s)}")
9
13
  end
10
14
 
11
15
  encoded_params.join("&")
@@ -1 +1 @@
1
- VERSION = "2.0.0"
1
+ VERSION = "2.0.1"
@@ -105,10 +105,10 @@ describe Encoder do
105
105
  })
106
106
  serialized = Encoder.new.serialize_request(req)
107
107
 
108
- expect(serialized).to eq("key=value+with+a+space&another_key=1013")
108
+ expect(serialized).to eq("key=value%20with%20a%20space&another_key=1013")
109
109
  end
110
110
 
111
- it 'encodes different special/unsafe characters when using CGI.escape' do
111
+ it 'encodes different special/unsafe characters when using a URI parser' do
112
112
  req = OpenStruct.new({
113
113
  :verb => "POST",
114
114
  :path => "/v1/api",
@@ -116,13 +116,29 @@ describe Encoder do
116
116
  "content-type" => "application/x-www-form-urlencoded; charset=utf8"
117
117
  },
118
118
  :body => {
119
- :key => " ..<..>..%..{..}..|../..^..`..!",
119
+ :key => " ..<..>..%..{..}..|..^..`..!",
120
120
  :another_key => 1013,
121
121
  }
122
122
  })
123
123
  serialized = Encoder.new.serialize_request(req)
124
124
 
125
- expect(serialized).to eq("key=+..%3C..%3E..%25..%7B..%7D..%7C..%2F..%5E..%60..%21&another_key=1013")
125
+ expect(serialized).to eq("key=%20..%3C..%3E..%25..%7B..%7D..%7C..%5E..%60..!&another_key=1013")
126
+ end
127
+
128
+ it 'does not encode links given certain special characters' do
129
+ req = OpenStruct.new({
130
+ :verb => "POST",
131
+ :path => "/v1/api",
132
+ :headers => {
133
+ "content-type" => "application/x-www-form-urlencoded; charset=utf8"
134
+ },
135
+ :body => {
136
+ :key => "https://localhost:3001/"
137
+ }
138
+ })
139
+ serialized = Encoder.new.serialize_request(req)
140
+
141
+ expect(serialized).to eq("key=https://localhost:3001/")
126
142
  end
127
143
 
128
144
  it 'throws when content-type is unsupported' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypalhttp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-25 00:00:00.000000000 Z
11
+ date: 2022-07-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Used for generated API clients
14
14
  email: