httparty 0.15.4 → 0.15.5
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 +4 -4
- data/Changelog.md +6 -0
- data/lib/httparty/parser.rb +1 -1
- data/lib/httparty/version.rb +1 -1
- data/spec/httparty/parser_spec.rb +30 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3abfd0d8679e4054bc591215e90d767d5024cbf6
|
4
|
+
data.tar.gz: 38fa4872a3e9cef824a947443b5d7eb3bb04a709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b398852558384d98d88f73c750e9e41ec93ae631b7f7de00f382d11087b70eae9ccf620a3cd99513f8b926caa97af5f7f3d6ec319b984c004759fad2a3cd22fe
|
7
|
+
data.tar.gz: bb01e3e75b9cf968aa6196843e66366679b0242833a89e488e6d589f67083cd4fde486bfeef56fd32386da214107e8dc9e10b3d482f8dca0496257e9b5e388ca
|
data/Changelog.md
CHANGED
data/lib/httparty/parser.rb
CHANGED
@@ -102,7 +102,7 @@ module HTTParty
|
|
102
102
|
return nil if body == "null"
|
103
103
|
return nil if body.valid_encoding? && body.strip.empty?
|
104
104
|
if body.valid_encoding? && body.encoding == Encoding::UTF_8
|
105
|
-
body.gsub
|
105
|
+
@body = body.gsub(/\A#{UTF8_BOM}/, '')
|
106
106
|
end
|
107
107
|
if supports_format?
|
108
108
|
parse_supported_format
|
data/lib/httparty/version.rb
CHANGED
@@ -63,57 +63,62 @@ RSpec.describe HTTParty::Parser do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#parse" do
|
66
|
-
before do
|
67
|
-
@parser = HTTParty::Parser.new('body', :json)
|
68
|
-
end
|
69
|
-
|
70
66
|
it "attempts to parse supported formats" do
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
parser = HTTParty::Parser.new('body', :json)
|
68
|
+
allow(parser).to receive_messages(supports_format?: true)
|
69
|
+
|
70
|
+
expect(parser).to receive(:parse_supported_format)
|
71
|
+
parser.parse
|
74
72
|
end
|
75
73
|
|
76
74
|
it "returns the unparsed body when the format is unsupported" do
|
77
|
-
|
78
|
-
|
75
|
+
parser = HTTParty::Parser.new('body', :json)
|
76
|
+
allow(parser).to receive_messages(supports_format?: false)
|
77
|
+
|
78
|
+
expect(parser.parse).to eq(parser.body)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "returns nil for an empty body" do
|
82
|
-
|
83
|
-
expect(
|
82
|
+
parser = HTTParty::Parser.new('', :json)
|
83
|
+
expect(parser.parse).to be_nil
|
84
84
|
end
|
85
85
|
|
86
86
|
it "returns nil for a nil body" do
|
87
|
-
|
88
|
-
expect(
|
87
|
+
parser = HTTParty::Parser.new(nil, :json)
|
88
|
+
expect(parser.parse).to be_nil
|
89
89
|
end
|
90
90
|
|
91
91
|
it "returns nil for a 'null' body" do
|
92
|
-
|
93
|
-
expect(
|
92
|
+
parser = HTTParty::Parser.new("null", :json)
|
93
|
+
expect(parser.parse).to be_nil
|
94
94
|
end
|
95
95
|
|
96
96
|
it "returns nil for a body with spaces only" do
|
97
|
-
|
98
|
-
expect(
|
97
|
+
parser = HTTParty::Parser.new(" ", :json)
|
98
|
+
expect(parser.parse).to be_nil
|
99
99
|
end
|
100
100
|
|
101
101
|
it "does not raise exceptions for bodies with invalid encodings" do
|
102
|
-
|
103
|
-
|
104
|
-
expect(@parser.parse).to_not be_nil
|
102
|
+
parser = HTTParty::Parser.new("\x80", :invalid_format)
|
103
|
+
expect(parser.parse).to_not be_nil
|
105
104
|
end
|
106
105
|
|
107
106
|
it "ignores utf-8 bom" do
|
108
|
-
|
109
|
-
expect(
|
107
|
+
parser = HTTParty::Parser.new("\xEF\xBB\xBF\{\"hi\":\"yo\"\}", :json)
|
108
|
+
expect(parser.parse).to eq({"hi"=>"yo"})
|
110
109
|
end
|
111
110
|
|
112
111
|
it "parses ascii 8bit encoding" do
|
113
|
-
|
114
|
-
|
112
|
+
parser = HTTParty::Parser.new(
|
113
|
+
"{\"currency\":\"\xE2\x82\xAC\"}".force_encoding('ASCII-8BIT'),
|
114
|
+
:json
|
115
115
|
)
|
116
|
-
expect(
|
116
|
+
expect(parser.parse).to eq({"currency" => "€"})
|
117
|
+
end
|
118
|
+
|
119
|
+
it "parses frozen strings" do
|
120
|
+
parser = HTTParty::Parser.new('{"a":1}'.freeze, :json)
|
121
|
+
expect(parser.parse).to eq("a" => 1)
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
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.
|
4
|
+
version: 0.15.5
|
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-
|
12
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|