oj 3.3.8 → 3.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/oj/dump.c +26 -16
  4. data/lib/oj/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28fc69ea25c02c80fd4d5d1622f05350e0fd6d5e
4
- data.tar.gz: 143ef4198b371f30dbdd12d8e4f1ecd4b43cdb08
3
+ metadata.gz: 4f086bef3216ed10da36f2302af180253dfdd2db
4
+ data.tar.gz: e1dfb9a7d1ec308b19ec532adb2dc320fcf6bf8b
5
5
  SHA512:
6
- metadata.gz: b0478c6f09d46f53827b981ed947002c8b723884c83276384b1316f2d85db9dd29dba0095d4d6a8d618062c313954d5883e05b08e8ba016bb949aae43b797dad
7
- data.tar.gz: 826fdefe54a411b7b92cc5563caeacccced2a7c0a25f869e1995fca3309cef7e4692e0ddb6e219317e788cc40daf3ddd4c0eb1c45bc932b4ab0e44a7c9d44bae
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
 
@@ -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
- char buf[1024];
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)cnt && i < 4; i++) {
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
- rb_raise(oj_json_generator_error_class, "Partial character in string.");
847
+ debug_raise(orig, cnt, __LINE__);
838
848
  }
839
849
  break;
840
850
  case 2:
841
851
  if (0xE0 != (0xF0 & c)) {
842
- rb_raise(oj_json_generator_error_class, "Partial character in string.");
852
+ debug_raise(orig, cnt, __LINE__);
843
853
  }
844
854
  break;
845
855
  case 3:
846
856
  if (0xF0 != (0xF8 & c)) {
847
- rb_raise(oj_json_generator_error_class, "Partial character in string.");
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)cnt || 4 <= i) {
857
- rb_raise(oj_json_generator_error_class, "Partial character in string.");
866
+ if (i == (int)scnt || 4 <= i) {
867
+ debug_raise(orig, cnt, __LINE__);
858
868
  }
859
869
  }
860
870
  *out->cur = '\0';
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.3.8'
4
+ VERSION = '3.3.9'
5
5
  end
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.8
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-04 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler