httparty 0.15.3 → 0.15.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79fe2cddc91ec18f47159ed37d6f30b7a87b12ca
4
- data.tar.gz: 6cbcf133a62890a8ce58667478b7c1f3e5a449fb
3
+ metadata.gz: 719a35806296e11c532ef8d283a1e8548da74cc6
4
+ data.tar.gz: 3f4b75c1eb74d848567010da60fe02cf12d6eeeb
5
5
  SHA512:
6
- metadata.gz: 38a54d1d643875d108d1f77f3d7d6a8f1132eec84048e3eed2f44dacec6b5aeea360581496dc22c3d3d4cea375c4616cd51cf4e68e8f317f482ce1120e151424
7
- data.tar.gz: 0200edc00c38b810a16dd5ff25bd5342d941fd7f6b38df2308414ad5dc16249fa79a013fe307e0496951ec07069e554c99fb50ff554669532bc158e0ef64cc4e
6
+ metadata.gz: f37c05926db73533186f453bd7b1b258b7e1da0bd6ec11baf7a46f56a5679ca34e3d2645837747a5343c12c2dfbb036e86b8ef33a4f59544657a98ab362ac6fe
7
+ data.tar.gz: 1fe1275d5477089a7c501ca6dbb15cf2db55f85ca92b49d2fa3ceb7d35429d764a9bdd3b1cff66ec20a6d79901bb8c91dde5f9ded3abf0fa1c2f23047f6fe969
@@ -1,3 +1,10 @@
1
+ ## 0.15.4
2
+
3
+ Fixed
4
+
5
+ * Prevent gsub errors with different encodings.
6
+ * Prevent passing nil to encode_body.
7
+
1
8
  ## 0.15.3
2
9
 
3
10
  Fixed
@@ -101,6 +101,9 @@ module HTTParty
101
101
  return nil if body.nil?
102
102
  return nil if body == "null"
103
103
  return nil if body.valid_encoding? && body.strip.empty?
104
+ if body.valid_encoding? && body.encoding == Encoding::UTF_8
105
+ body.gsub!(/\A#{UTF8_BOM}/, '')
106
+ end
104
107
  if supports_format?
105
108
  parse_supported_format
106
109
  else
@@ -117,7 +120,7 @@ module HTTParty
117
120
  UTF8_BOM = "\xEF\xBB\xBF".freeze
118
121
 
119
122
  def json
120
- JSON.parse(body.gsub(/\A#{UTF8_BOM}/, ''), :quirks_mode => true, :allow_nan => true)
123
+ JSON.parse(body, :quirks_mode => true, :allow_nan => true)
121
124
  end
122
125
 
123
126
  def csv
@@ -60,7 +60,7 @@ module HTTParty
60
60
  connection_adapter: ConnectionAdapter
61
61
  }.merge(o)
62
62
  self.path = path
63
- set_basic_auth_from_uri
63
+ set_basic_auth_from_uri
64
64
  end
65
65
 
66
66
  def path=(uri)
@@ -151,18 +151,18 @@ module HTTParty
151
151
  chunked_body = chunks.join
152
152
  end
153
153
  end
154
-
155
-
154
+
155
+
156
156
  handle_host_redirection if response_redirects?
157
157
  result = handle_unauthorized
158
158
  result ||= handle_response(chunked_body, &block)
159
- result
159
+ result
160
160
  end
161
161
 
162
162
  def handle_unauthorized(&block)
163
163
  return unless digest_auth? && response_unauthorized? && response_has_digest_auth_challenge?
164
164
  return if @credentials_sent
165
- @credentials_sent = true
165
+ @credentials_sent = true
166
166
  perform(&block)
167
167
  end
168
168
 
@@ -210,9 +210,9 @@ module HTTParty
210
210
  @raw_request.body_stream = options[:body_stream] if options[:body_stream]
211
211
  if options[:headers].respond_to?(:to_hash)
212
212
  headers_hash = options[:headers].to_hash
213
-
213
+
214
214
  @raw_request.initialize_http_header(headers_hash)
215
- # If the caller specified a header of 'Accept-Encoding', assume they want to
215
+ # If the caller specified a header of 'Accept-Encoding', assume they want to
216
216
  # deal with encoding of content. Disable the internal logic in Net:HTTP
217
217
  # that handles encoding, if the platform supports it.
218
218
  if @raw_request.respond_to?(:decode_content) && (headers_hash.key?('Accept-Encoding') || headers_hash.key?('accept-encoding'))
@@ -220,10 +220,10 @@ module HTTParty
220
220
  @raw_request['accept-encoding'] = @raw_request['accept-encoding']
221
221
  end
222
222
  end
223
- if options[:basic_auth] && send_authorization_header?
223
+ if options[:basic_auth] && send_authorization_header?
224
224
  @raw_request.basic_auth(username, password)
225
225
  @credentials_sent = true
226
- end
226
+ end
227
227
  setup_digest_auth if digest_auth? && response_unauthorized? && response_has_digest_auth_challenge?
228
228
  end
229
229
 
@@ -240,7 +240,7 @@ module HTTParty
240
240
  end
241
241
 
242
242
  def setup_digest_auth
243
- @raw_request.digest_auth(username, password, last_response)
243
+ @raw_request.digest_auth(username, password, last_response)
244
244
  end
245
245
 
246
246
  def query_string(uri)
@@ -278,9 +278,9 @@ module HTTParty
278
278
  def encode_with_ruby_encoding(body, charset)
279
279
  if !body.nil? && Encoding.name_list.include?(charset)
280
280
  body.force_encoding(charset)
281
- else
281
+ else
282
282
  body
283
- end
283
+ end
284
284
  end
285
285
 
286
286
  def assume_utf16_is_big_endian
@@ -347,7 +347,7 @@ module HTTParty
347
347
  perform(&block)
348
348
  else
349
349
  body ||= last_response.body
350
- body = encode_body(body)
350
+ body = body.nil? ? body : encode_body(body)
351
351
  Response.new(self, last_response, lambda { parse_response(body) }, body: body)
352
352
  end
353
353
  end
@@ -367,7 +367,7 @@ module HTTParty
367
367
  end
368
368
 
369
369
  def send_authorization_header?
370
- !@changed_hosts
370
+ !@changed_hosts
371
371
  end
372
372
 
373
373
  def response_redirects?
@@ -388,7 +388,7 @@ module HTTParty
388
388
  cookies_hash = HTTParty::CookieHash.new
389
389
  cookies_hash.add_cookies(options[:headers].to_hash['Cookie']) if options[:headers] && options[:headers].to_hash['Cookie']
390
390
  response.get_fields('Set-Cookie').each { |cookie| cookies_hash.add_cookies(cookie) }
391
-
391
+
392
392
  options[:headers] ||= {}
393
393
  options[:headers]['Cookie'] = cookies_hash.to_cookie_string
394
394
  end
@@ -1,3 +1,3 @@
1
1
  module HTTParty
2
- VERSION = "0.15.3"
2
+ VERSION = "0.15.4"
3
3
  end
@@ -108,6 +108,13 @@ RSpec.describe HTTParty::Parser do
108
108
  allow(@parser).to receive_messages(body: "\xEF\xBB\xBF\{\"hi\":\"yo\"\}")
109
109
  expect(@parser.parse).to eq({"hi"=>"yo"})
110
110
  end
111
+
112
+ it "parses ascii 8bit encoding" do
113
+ allow(@parser).to receive_messages(
114
+ body: "{\"currency\":\"\xE2\x82\xAC\"}".force_encoding('ASCII-8BIT')
115
+ )
116
+ expect(@parser.parse).to eq({"currency" => "€"})
117
+ end
111
118
  end
112
119
 
113
120
  describe "#supports_format?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-16 00:00:00.000000000 Z
12
+ date: 2017-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_xml