yajl-ruby 0.6.9 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yajl-ruby might be problematic. Click here for more details.
- data/CHANGELOG.md +3 -0
- data/VERSION.yml +2 -2
- data/ext/yajl_ext.c +24 -2
- data/ext/yajl_ext.h +5 -0
- data/lib/yajl.rb +1 -1
- data/spec/json_gem_compatibility/compatibility_spec.rb +1 -2
- data/yajl-ruby.gemspec +2 -2
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.7.0 (February 5th, 2010)
|
4
|
+
* ensure utf8 encoding is set on relevant strings during parse/encode in 1.9
|
5
|
+
|
3
6
|
## 0.6.9 (January 26th, 2010)
|
4
7
|
* HttpStream patches merged in from Luke Redpath <contact@lukeredpath.co.uk>
|
5
8
|
* Changed how Yajl::Parser was calling IO#read to better conform to the Rack spec and thus can be used to directly parse a rack.input stream
|
data/VERSION.yml
CHANGED
data/ext/yajl_ext.c
CHANGED
@@ -263,7 +263,11 @@ static int yajl_found_number(void * ctx, const char * numberVal, unsigned int nu
|
|
263
263
|
}
|
264
264
|
|
265
265
|
static int yajl_found_string(void * ctx, const unsigned char * stringVal, unsigned int stringLen) {
|
266
|
-
|
266
|
+
VALUE str = rb_str_new((const char *)stringVal, stringLen);
|
267
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
268
|
+
rb_enc_associate_index(str, utf8Encoding);
|
269
|
+
#endif
|
270
|
+
yajl_set_static_value(ctx, str);
|
267
271
|
yajl_check_and_fire_callback(ctx);
|
268
272
|
return 1;
|
269
273
|
}
|
@@ -280,6 +284,9 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
|
|
280
284
|
yajl_set_static_value(ctx, ID2SYM(rb_intern(buf)));
|
281
285
|
} else {
|
282
286
|
keyStr = rb_str_new((const char *)stringVal, stringLen);
|
287
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
288
|
+
rb_enc_associate_index(keyStr, utf8Encoding);
|
289
|
+
#endif
|
283
290
|
yajl_set_static_value(ctx, keyStr);
|
284
291
|
}
|
285
292
|
yajl_check_and_fire_callback(ctx);
|
@@ -439,7 +446,7 @@ static VALUE rb_yajl_parser_parse(int argc, VALUE * argv, VALUE self) {
|
|
439
446
|
cptr = RSTRING_PTR(input);
|
440
447
|
yajl_parse_chunk((const unsigned char*)cptr, (unsigned int)strlen(cptr), wrapper->parser);
|
441
448
|
} else if (rb_respond_to(input, intern_eof)) {
|
442
|
-
VALUE parsed =
|
449
|
+
VALUE parsed = rb_str_new("", READ_BUFSIZE);
|
443
450
|
while (rb_funcall(input, intern_eof, 0) != Qtrue) {
|
444
451
|
parsed = rb_funcall(input, intern_io_read, 1, rbufsize);
|
445
452
|
cptr = RSTRING_PTR(parsed);
|
@@ -544,6 +551,9 @@ static VALUE rb_yajl_encoder_new(int argc, VALUE * argv, VALUE klass) {
|
|
544
551
|
beautify = 1;
|
545
552
|
indent = rb_hash_aref(opts, sym_indent);
|
546
553
|
if (indent != Qnil) {
|
554
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
555
|
+
rb_enc_associate_index(indent, utf8Encoding);
|
556
|
+
#endif
|
547
557
|
Check_Type(indent, T_STRING);
|
548
558
|
indentString = RSTRING_PTR(indent);
|
549
559
|
}
|
@@ -556,6 +566,11 @@ static VALUE rb_yajl_encoder_new(int argc, VALUE * argv, VALUE klass) {
|
|
556
566
|
wrapper->on_progress_callback = Qnil;
|
557
567
|
if (opts != Qnil && rb_funcall(opts, intern_has_key, 1, sym_terminator) == Qtrue) {
|
558
568
|
wrapper->terminator = rb_hash_aref(opts, sym_terminator);
|
569
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
570
|
+
if (TYPE(wrapper->terminator) == T_STRING) {
|
571
|
+
rb_enc_associate_index(wrapper->terminator, utf8Encoding);
|
572
|
+
}
|
573
|
+
#endif
|
559
574
|
} else {
|
560
575
|
wrapper->terminator = 0;
|
561
576
|
}
|
@@ -618,6 +633,9 @@ static VALUE rb_yajl_encoder_encode(int argc, VALUE * argv, VALUE self) {
|
|
618
633
|
/* just make sure we output the remaining buffer */
|
619
634
|
yajl_gen_get_buf(wrapper->encoder, &buffer, &len);
|
620
635
|
outBuff = rb_str_new((const char *)buffer, len);
|
636
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
637
|
+
rb_enc_associate_index(outBuff, utf8Encoding);
|
638
|
+
#endif
|
621
639
|
yajl_gen_clear(wrapper->encoder);
|
622
640
|
|
623
641
|
if (io != Qnil) {
|
@@ -890,4 +908,8 @@ void Init_yajl_ext() {
|
|
890
908
|
sym_indent = ID2SYM(rb_intern("indent"));
|
891
909
|
sym_terminator = ID2SYM(rb_intern("terminator"));
|
892
910
|
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
|
911
|
+
|
912
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
913
|
+
utf8Encoding = rb_enc_find_index("UTF-8");
|
914
|
+
#endif
|
893
915
|
}
|
data/ext/yajl_ext.h
CHANGED
data/lib/yajl.rb
CHANGED
@@ -13,7 +13,7 @@ require 'yajl_ext'
|
|
13
13
|
#
|
14
14
|
# Ruby bindings to the excellent Yajl (Yet Another JSON Parser) ANSI C library.
|
15
15
|
module Yajl
|
16
|
-
VERSION = "0.
|
16
|
+
VERSION = "0.7.0"
|
17
17
|
|
18
18
|
# For compatibility, has the same signature of Yajl::Parser.parse
|
19
19
|
def self.load(str_or_io, options={}, read_bufsize=nil, &block)
|
@@ -81,7 +81,6 @@ describe "JSON Gem compatability API" do
|
|
81
81
|
|
82
82
|
context "ported tests for Unicode" do
|
83
83
|
it "should be able to encode and parse unicode" do
|
84
|
-
pending if RUBY_VERSION.include?('1.9') # FIXME: Some string encoding problem with 1.9
|
85
84
|
'""'.should eql(''.to_json)
|
86
85
|
'"\\b"'.should eql("\b".to_json)
|
87
86
|
'"\u0001"'.should eql(0x1.chr.to_json)
|
@@ -89,7 +88,7 @@ describe "JSON Gem compatability API" do
|
|
89
88
|
'" "'.should eql(' '.to_json)
|
90
89
|
"\"#{0x7f.chr}\"".should eql(0x7f.chr.to_json)
|
91
90
|
utf8 = [ "© ≠ €! \01" ]
|
92
|
-
json =
|
91
|
+
json = "[\"© ≠ €! \\u0001\"]"
|
93
92
|
json.should eql(utf8.to_json)
|
94
93
|
utf8.should eql(JSON.parse(json))
|
95
94
|
utf8 = ["\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212"]
|
data/yajl-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yajl-ruby}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Lopez", "Lloyd Hilaiel"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-05}
|
13
13
|
s.email = %q{seniorlopez@gmail.com}
|
14
14
|
s.extensions = ["ext/extconf.rb"]
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yajl-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-02-05 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|