ffi-yajl 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -0
- data/lib/ffi_yajl/encoder.rb +15 -2
- data/lib/ffi_yajl/version.rb +1 -1
- data/spec/ffi_yajl/encoder_spec.rb +14 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d781f4b2a16bfdf584c9e5e18aacc4acead4e2d1
|
4
|
+
data.tar.gz: b983d62ab1c69061965c697c28d4a2f3eb903fff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ff1a41b3526497a2c8b76ddba312121973aa1191d968e284ca084c96db7c243dc38f01443de87c0673565f09a68604586e0a036732fbda6a18dda24d590f524
|
7
|
+
data.tar.gz: ab3ac6089aa276b4937ec8c51cffc76800e1595d17b40c6449df7cd30edeeba27959c87a34ed1fea658c6b8a1fbbbc4198591748630a4c6c8e7123de2f182f5d
|
data/Rakefile
CHANGED
@@ -4,12 +4,18 @@ require 'rspec/core/rake_task'
|
|
4
4
|
require 'rubygems/package_task'
|
5
5
|
require 'rake/extensiontask'
|
6
6
|
require 'ffi_yajl/version'
|
7
|
+
require 'github_changelog_generator/task'
|
7
8
|
|
8
9
|
Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
|
9
10
|
gemspec = eval(IO.read(gemspec_path))
|
10
11
|
Gem::PackageTask.new(gemspec).define
|
11
12
|
end
|
12
13
|
|
14
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
15
|
+
config.since_tag = '1.0.1'
|
16
|
+
config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
|
17
|
+
end
|
18
|
+
|
13
19
|
desc "Build it and ship it"
|
14
20
|
task ship: [:clean, :gem] do
|
15
21
|
sh("git tag #{FFI_Yajl::VERSION}")
|
data/lib/ffi_yajl/encoder.rb
CHANGED
@@ -41,7 +41,15 @@ module FFI_Yajl
|
|
41
41
|
# call either the ext or ffi hook
|
42
42
|
str = do_yajl_encode(obj, yajl_gen_opts, opts)
|
43
43
|
# we can skip cleaning the whole string for utf-8 issues if we have yajl validate as we go
|
44
|
-
|
44
|
+
|
45
|
+
str.force_encoding("UTF-8")
|
46
|
+
unless yajl_gen_opts[:yajl_gen_validate_utf8]
|
47
|
+
if str.respond_to?(:scrub)
|
48
|
+
str.scrub!
|
49
|
+
else
|
50
|
+
str.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8')
|
51
|
+
end
|
52
|
+
end
|
45
53
|
str
|
46
54
|
end
|
47
55
|
|
@@ -56,7 +64,12 @@ module FFI_Yajl
|
|
56
64
|
|
57
65
|
def self.raise_error_for_status(status, token = nil)
|
58
66
|
# scrub token to valid utf-8 since we may be issuing an exception on an invalid utf-8 token
|
59
|
-
token = token.to_s.
|
67
|
+
token = token.to_s.force_encoding("UTF-8")
|
68
|
+
if token.respond_to?(:scrub)
|
69
|
+
token.scrub!
|
70
|
+
else
|
71
|
+
token.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8')
|
72
|
+
end
|
60
73
|
case status
|
61
74
|
when 1 # yajl_gen_keys_must_be_strings
|
62
75
|
raise FFI_Yajl::EncodeError, "YAJL internal error: attempted use of non-string object as key"
|
data/lib/ffi_yajl/version.rb
CHANGED
@@ -180,13 +180,14 @@ describe "FFI_Yajl::Encoder" do
|
|
180
180
|
"passwd" => {
|
181
181
|
"root" => { "dir" => "/root", "gid" => 0, "uid" => 0, "shell" => "/bin/sh", "gecos" => "Elan Ruusam\xc3\xa4e" },
|
182
182
|
"glen" => { "dir" => "/home/glen", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Elan Ruusam\xE4e" },
|
183
|
+
"helmüt" => { "dir" => "/home/helmüt", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Hañs Helmüt" },
|
183
184
|
},
|
184
185
|
},
|
185
186
|
},
|
186
187
|
}
|
187
188
|
|
188
189
|
it "raises an error on invalid json" do
|
189
|
-
expect { encoder.encode(ruby) }.to raise_error(FFI_Yajl::EncodeError, /Invalid UTF-8 string 'Elan Ruusam
|
190
|
+
expect { encoder.encode(ruby) }.to raise_error(FFI_Yajl::EncodeError, /Invalid UTF-8 string 'Elan Ruusam.*': cannot encode to UTF-8/)
|
190
191
|
end
|
191
192
|
|
192
193
|
context "when validate_utf8 is off" do
|
@@ -203,6 +204,18 @@ describe "FFI_Yajl::Encoder" do
|
|
203
204
|
it "returns valid utf8" do
|
204
205
|
expect( encoder.encode(ruby).valid_encoding? ).to be true
|
205
206
|
end
|
207
|
+
|
208
|
+
it "does not mangle valid utf8" do
|
209
|
+
json = encoder.encode(ruby)
|
210
|
+
expect(json).to match(/Hañs Helmüt/)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "does not grow after a round trip" do
|
214
|
+
json = encoder.encode(ruby)
|
215
|
+
ruby2 = FFI_Yajl::Parser.parse(json)
|
216
|
+
json2 = encoder.encode(ruby2)
|
217
|
+
expect(json).to eql(json2)
|
218
|
+
end
|
206
219
|
end
|
207
220
|
end
|
208
221
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-yajl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lamont Granquist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.9.
|
180
|
+
version: 1.9.3
|
181
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
182
|
requirements:
|
183
183
|
- - ">="
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.4.
|
188
|
+
rubygems_version: 2.4.8
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Ruby FFI wrapper around YAJL 2.x
|