oj 3.3.8 → 3.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/oj/dump.c +26 -16
- data/lib/oj/version.rb +1 -1
- 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: 4f086bef3216ed10da36f2302af180253dfdd2db
|
4
|
+
data.tar.gz: e1dfb9a7d1ec308b19ec532adb2dc320fcf6bf8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c5a71807363fcd682474d42760199bc8f4709505648c63aebbc9dadbc91677ae27f82c4712973d5fe01935998dcff46c611c92a920b39016d217a6c3cfd3a7
|
7
|
+
data.tar.gz: fb39fbaae9c45f79ff49f30ab624838d3c7b2061d7aa6d891dc2c05e8f7cffd2dcd48bf08618264a12f6ad0092206de7a12b9c11773dae8f7fc0c38c8c27c22f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# [![{}j](http://www.ohler.com/dev/images/oj_comet_64.svg)](http://www.ohler.com/oj) gem
|
2
2
|
|
3
|
-
[![Build Status](https://img.shields.io/travis/ohler55/oj/master.svg)](http://travis-ci.org/ohler55/oj?branch=master) [![AppVeyor](https://img.shields.io/appveyor/ci/ohler55/oj/master.svg)](https://ci.appveyor.com/project/ohler55/oj) ![Gem](https://img.shields.io/gem/v/oj.svg) ![Gem](https://img.shields.io/gem/dt/oj.svg)
|
3
|
+
[![Build Status](https://img.shields.io/travis/ohler55/oj/master.svg)](http://travis-ci.org/ohler55/oj?branch=master) [![AppVeyor](https://img.shields.io/appveyor/ci/ohler55/oj/master.svg)](https://ci.appveyor.com/project/ohler55/oj) ![Gem](https://img.shields.io/gem/v/oj.svg) ![Gem](https://img.shields.io/gem/dt/oj.svg) [![Gratipay](https://img.shields.io/gratipay/project/oj.svg)](https://gratipay.com/oj/)
|
4
4
|
|
5
5
|
A *fast* JSON parser and Object marshaller as a Ruby gem.
|
6
6
|
|
data/ext/oj/dump.c
CHANGED
@@ -685,6 +685,23 @@ oj_dump_sym(VALUE obj, int depth, Out out, bool as_ok) {
|
|
685
685
|
oj_dump_cstr(sym, strlen(sym), 0, 0, out);
|
686
686
|
}
|
687
687
|
|
688
|
+
static void
|
689
|
+
debug_raise(const char *orig, size_t cnt, int line) {
|
690
|
+
char buf[1024];
|
691
|
+
char *b = buf;
|
692
|
+
const char *s = orig;
|
693
|
+
const char *s_end = s + cnt;
|
694
|
+
|
695
|
+
if (32 < s_end - s) {
|
696
|
+
s_end = s + 32;
|
697
|
+
}
|
698
|
+
for (; s < s_end; s++) {
|
699
|
+
b += sprintf(b, " %02x", *s);
|
700
|
+
}
|
701
|
+
*b = '\0';
|
702
|
+
rb_raise(oj_json_generator_error_class, "Partial character in string. %s @ %d", buf, line);
|
703
|
+
}
|
704
|
+
|
688
705
|
void
|
689
706
|
oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out) {
|
690
707
|
size_t size;
|
@@ -810,41 +827,34 @@ oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out) {
|
|
810
827
|
}
|
811
828
|
*out->cur++ = '"';
|
812
829
|
}
|
813
|
-
if (JXEsc == out->opts->escape_mode && 0 != (0x80 & *(str - 1))) {
|
830
|
+
if (JXEsc == out->opts->escape_mode && 0 < str - orig && 0 != (0x80 & *(str - 1))) {
|
814
831
|
uint8_t c = (uint8_t)*(str - 1);
|
815
832
|
int i;
|
833
|
+
int scnt = str - orig;
|
816
834
|
|
817
835
|
// Last utf-8 characters must be 0x10xxxxxx. The start must be
|
818
836
|
// 0x110xxxxx for 2 characters, 0x1110xxxx for 3, and 0x11110xxx for
|
819
837
|
// 4.
|
820
838
|
if (0 != (0x40 & c)) {
|
821
|
-
|
822
|
-
char *b = buf;
|
823
|
-
const char *s = orig;
|
824
|
-
|
825
|
-
for (; s < s + cnt; s++) {
|
826
|
-
b += sprintf(b, " %02x", *s);
|
827
|
-
}
|
828
|
-
*b = '\0';
|
829
|
-
rb_raise(oj_json_generator_error_class, "Partial character in string. %s", buf);
|
839
|
+
debug_raise(orig, cnt, __LINE__);
|
830
840
|
}
|
831
|
-
for (i = 1; i < (int)
|
841
|
+
for (i = 1; i < (int)scnt && i < 4; i++) {
|
832
842
|
c = str[-1 - i];
|
833
843
|
if (0x80 != (0xC0 & c)) {
|
834
844
|
switch (i) {
|
835
845
|
case 1:
|
836
846
|
if (0xC0 != (0xE0 & c)) {
|
837
|
-
|
847
|
+
debug_raise(orig, cnt, __LINE__);
|
838
848
|
}
|
839
849
|
break;
|
840
850
|
case 2:
|
841
851
|
if (0xE0 != (0xF0 & c)) {
|
842
|
-
|
852
|
+
debug_raise(orig, cnt, __LINE__);
|
843
853
|
}
|
844
854
|
break;
|
845
855
|
case 3:
|
846
856
|
if (0xF0 != (0xF8 & c)) {
|
847
|
-
|
857
|
+
debug_raise(orig, cnt, __LINE__);
|
848
858
|
}
|
849
859
|
break;
|
850
860
|
default: // can't get here
|
@@ -853,8 +863,8 @@ oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out) {
|
|
853
863
|
break;
|
854
864
|
}
|
855
865
|
}
|
856
|
-
if (i == (int)
|
857
|
-
|
866
|
+
if (i == (int)scnt || 4 <= i) {
|
867
|
+
debug_raise(orig, cnt, __LINE__);
|
858
868
|
}
|
859
869
|
}
|
860
870
|
*out->cur = '\0';
|
data/lib/oj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|