ox 2.8.1 → 2.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 232bced785428a91e7638a049331d4f5df83974e
4
- data.tar.gz: 23620f39d27521174900856190b6ced9d3715427
3
+ metadata.gz: 066b29e775aa1fbf8beb40e572299a3b99155c92
4
+ data.tar.gz: 41c0e36f4f7bbebcef8f27c7e75d80c3c6420423
5
5
  SHA512:
6
- metadata.gz: 8f5fe521ffeb36fe836b331bf7f7d9b2888e6aa27ff4873224a6084de055289fa19258b47bdc9d49acae5495834a46834001ee81f2cdbcb8cd85e8fa75f84cf3
7
- data.tar.gz: 5c80d1a9b238bc452c67fee28739238c385dc28c4641dadec6dbfe0f4408e5c0cc1f0e18d4c2df51fa9ee3d0d1c9b790d5d3f929bd1d3255241451248f591353
6
+ metadata.gz: fbdf712b54810a1bff6c211d0f4b7e63ee8a1ed48911b4d43491c3792acd44c3f32bdc6da7028f8de87dfcc937162bb8116e13c9d73c1a60998a7eafb71efa24
7
+ data.tar.gz: f7378812079495da8752277b52c7372e739b848e24cf1845eb6e1d48e625d560c93374373d7d429b2612111b2173a9ce180a32385734e3b2f8e073f0937b143a
@@ -1,4 +1,10 @@
1
1
 
2
+ ## 2.8.2 - November 1, 2017
3
+
4
+ - Fixed bug with SAX parser that caused a crash with very long invalid instruction element.
5
+
6
+ - Fixed SAX parse error with double <source> elements.
7
+
2
8
  ## 2.8.1 - October 27, 2017
3
9
 
4
10
  - Avoid crash with invalid XML passed to Oj.parse_obj().
@@ -537,8 +537,8 @@ set_def_opts(VALUE self, VALUE opts) {
537
537
  Check_Type(v, T_STRING);
538
538
  slen = RSTRING_LEN(v);
539
539
  if (sizeof(ox_default_options.inv_repl) - 2 < (size_t)slen) {
540
- rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %ld characters.",
541
- sizeof(ox_default_options.inv_repl) - 2);
540
+ rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %d characters.",
541
+ (int)sizeof(ox_default_options.inv_repl) - 2);
542
542
  }
543
543
  strncpy(ox_default_options.inv_repl + 1, StringValuePtr(v), sizeof(ox_default_options.inv_repl) - 1);
544
544
  ox_default_options.inv_repl[sizeof(ox_default_options.inv_repl) - 1] = '\0';
@@ -558,8 +558,8 @@ set_def_opts(VALUE self, VALUE opts) {
558
558
  Check_Type(v, T_STRING);
559
559
  slen = RSTRING_LEN(v);
560
560
  if (sizeof(ox_default_options.strip_ns) - 1 < (size_t)slen) {
561
- rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %ld characters.",
562
- sizeof(ox_default_options.strip_ns) - 1);
561
+ rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %d characters.",
562
+ (int)sizeof(ox_default_options.strip_ns) - 1);
563
563
  }
564
564
  strncpy(ox_default_options.strip_ns, StringValuePtr(v), sizeof(ox_default_options.strip_ns) - 1);
565
565
  ox_default_options.strip_ns[sizeof(ox_default_options.strip_ns) - 1] = '\0';
@@ -572,8 +572,8 @@ set_def_opts(VALUE self, VALUE opts) {
572
572
  Check_Type(v, T_STRING);
573
573
  slen = RSTRING_LEN(v);
574
574
  if (sizeof(ox_default_options.margin) - 1 < (size_t)slen) {
575
- rb_raise(ox_parse_error_class, ":margin can be no longer than %ld characters.",
576
- sizeof(ox_default_options.margin) - 1);
575
+ rb_raise(ox_parse_error_class, ":margin can be no longer than %d characters.",
576
+ (int)sizeof(ox_default_options.margin) - 1);
577
577
  }
578
578
  strncpy(ox_default_options.margin, StringValuePtr(v), sizeof(ox_default_options.margin) - 1);
579
579
  ox_default_options.margin[sizeof(ox_default_options.margin) - 1] = '\0';
@@ -769,8 +769,8 @@ load(char *xml, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
769
769
  Check_Type(v, T_STRING);
770
770
  slen = RSTRING_LEN(v);
771
771
  if (sizeof(options.inv_repl) - 2 < (size_t)slen) {
772
- rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %ld characters.",
773
- sizeof(options.inv_repl) - 2);
772
+ rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %d characters.",
773
+ (int)sizeof(options.inv_repl) - 2);
774
774
  }
775
775
  strncpy(options.inv_repl + 1, StringValuePtr(v), sizeof(options.inv_repl) - 1);
776
776
  options.inv_repl[sizeof(options.inv_repl) - 1] = '\0';
@@ -789,8 +789,8 @@ load(char *xml, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
789
789
  Check_Type(v, T_STRING);
790
790
  slen = RSTRING_LEN(v);
791
791
  if (sizeof(options.strip_ns) - 1 < (size_t)slen) {
792
- rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %ld characters.",
793
- sizeof(options.strip_ns) - 1);
792
+ rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %d characters.",
793
+ (int)sizeof(options.strip_ns) - 1);
794
794
  }
795
795
  strncpy(options.strip_ns, StringValuePtr(v), sizeof(options.strip_ns) - 1);
796
796
  options.strip_ns[sizeof(options.strip_ns) - 1] = '\0';
@@ -802,8 +802,8 @@ load(char *xml, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
802
802
  Check_Type(v, T_STRING);
803
803
  slen = RSTRING_LEN(v);
804
804
  if (sizeof(options.margin) - 1 < (size_t)slen) {
805
- rb_raise(ox_parse_error_class, ":margin can be no longer than %ld characters.",
806
- sizeof(options.margin) - 1);
805
+ rb_raise(ox_parse_error_class, ":margin can be no longer than %d characters.",
806
+ (int)sizeof(options.margin) - 1);
807
807
  }
808
808
  strncpy(options.margin, StringValuePtr(v), sizeof(options.margin) - 1);
809
809
  options.margin[sizeof(options.margin) - 1] = '\0';
@@ -1055,8 +1055,8 @@ sax_parse(int argc, VALUE *argv, VALUE self) {
1055
1055
  Check_Type(v, T_STRING);
1056
1056
  slen = RSTRING_LEN(v);
1057
1057
  if (sizeof(options.strip_ns) - 1 < (size_t)slen) {
1058
- rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %ld characters.",
1059
- sizeof(options.strip_ns) - 1);
1058
+ rb_raise(ox_parse_error_class, ":strip_namespace can be no longer than %d characters.",
1059
+ (int)sizeof(options.strip_ns) - 1);
1060
1060
  }
1061
1061
  strncpy(options.strip_ns, StringValuePtr(v), sizeof(options.strip_ns) - 1);
1062
1062
  options.strip_ns[sizeof(options.strip_ns) - 1] = '\0';
@@ -1209,8 +1209,8 @@ parse_dump_options(VALUE ropts, Options copts) {
1209
1209
  Check_Type(v, T_STRING);
1210
1210
  slen = RSTRING_LEN(v);
1211
1211
  if (sizeof(copts->inv_repl) - 2 < (size_t)slen) {
1212
- rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %ld characters.",
1213
- sizeof(copts->inv_repl) - 2);
1212
+ rb_raise(ox_parse_error_class, ":invalid_replace can be no longer than %d characters.",
1213
+ (int)sizeof(copts->inv_repl) - 2);
1214
1214
  }
1215
1215
  strncpy(copts->inv_repl + 1, StringValuePtr(v), sizeof(copts->inv_repl) - 1);
1216
1216
  copts->inv_repl[sizeof(copts->inv_repl) - 1] = '\0';
@@ -1224,8 +1224,8 @@ parse_dump_options(VALUE ropts, Options copts) {
1224
1224
  Check_Type(v, T_STRING);
1225
1225
  slen = RSTRING_LEN(v);
1226
1226
  if (sizeof(copts->margin) - 2 < (size_t)slen) {
1227
- rb_raise(ox_parse_error_class, ":margin can be no longer than %ld characters.",
1228
- sizeof(copts->margin) - 2);
1227
+ rb_raise(ox_parse_error_class, ":margin can be no longer than %d characters.",
1228
+ (int)sizeof(copts->margin) - 2);
1229
1229
  }
1230
1230
  strncpy(copts->margin, StringValuePtr(v), sizeof(copts->margin) - 1);
1231
1231
  copts->margin[sizeof(copts->margin) - 1] = '\0';
@@ -448,7 +448,8 @@ read_content(SaxDrive dr, char *content, size_t len) {
448
448
  char *end = content + len;
449
449
 
450
450
  while ('\0' != (c = buf_get(&dr->buf))) {
451
- if (end < content) {
451
+ if (end <= content) {
452
+ *content = '\0';
452
453
  ox_sax_drive_error(dr, "processing instruction content too large");
453
454
  return;
454
455
  }
@@ -473,9 +474,9 @@ read_content(SaxDrive dr, char *content, size_t len) {
473
474
  */
474
475
  static char
475
476
  read_instruction(SaxDrive dr) {
476
- char content[1024];
477
+ char content[4096];
477
478
  char c;
478
- char *cend;
479
+ int coff;
479
480
  VALUE target = Qnil;
480
481
  int is_xml;
481
482
  int pos = dr->buf.pos - 1;
@@ -510,7 +511,7 @@ read_instruction(SaxDrive dr) {
510
511
  line = dr->buf.line;
511
512
  col = dr->buf.col;
512
513
  read_content(dr, content, sizeof(content) - 1);
513
- cend = dr->buf.tail;
514
+ coff = dr->buf.tail - dr->buf.head;
514
515
  buf_reset(&dr->buf);
515
516
  dr->err = 0;
516
517
  c = read_attrs(dr, c, '?', '?', is_xml, 1, NULL);
@@ -545,7 +546,7 @@ read_instruction(SaxDrive dr) {
545
546
  }
546
547
  rb_funcall2(dr->handler, ox_text_id, 1, args);
547
548
  }
548
- dr->buf.tail = cend;
549
+ dr->buf.tail = dr->buf.head + coff;
549
550
  c = buf_get(&dr->buf);
550
551
  } else {
551
552
  pos = dr->buf.pos;
@@ -925,7 +926,7 @@ read_element_start(SaxDrive dr) {
925
926
  end_element_cb(dr, top_nv->val, pos, line, col, top_nv->hint);
926
927
  top_nv = stack_peek(&dr->stack);
927
928
  }
928
- if (0 != h->parents && NestOverlay != h->overlay) {
929
+ if (NULL != top_nv && 0 != h->parents && NestOverlay != h->overlay) {
929
930
  const char **p;
930
931
  int ok = 0;
931
932
 
@@ -73,7 +73,7 @@ int
73
73
  ox_sax_buf_read(Buf buf) {
74
74
  int err;
75
75
  size_t shift = 0;
76
-
76
+
77
77
  // if there is not much room to read into, shift or realloc a larger buffer.
78
78
  if (buf->head < buf->tail && 4096 > buf->end - buf->tail) {
79
79
  if (0 == buf->pro) {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.8.1'
4
+ VERSION = '2.8.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.8.2
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-27 00:00:00.000000000 Z
11
+ date: 2017-11-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "A fast XML parser and object serializer that uses only standard C lib.\n
14
14
  \ \nOptimized XML (Ox), as the name implies was written to provide speed