ox 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0f1c9717a0c2a666b6131188f72dcb26b88230
4
- data.tar.gz: 93edf8cebd1ef9390ee531b957aa2369b4542a92
3
+ metadata.gz: 2b9a20f56f4e7eb7090f1ed2a58eab7f85276585
4
+ data.tar.gz: 7c2c55961c8286576d47b925d97f1073ab9722cd
5
5
  SHA512:
6
- metadata.gz: 7f2a045152966f88e3ed61aa5804810e3584afc8b05ba129b627c86e7343d9263b95bf39531158bed3d349e8b7dfc2cc7a1f58e7fe2023b53ecd004756e5d345
7
- data.tar.gz: cf8ab5d25d451ffaf01b8029f72c41bfdb521637189ed3df4a60e7e4ebd566ce8ada66bb397149aa60e9ca9958cf5a0553bb5616c42add5f418b8d4fc8ef7b3f
6
+ metadata.gz: 97a5d814b0cc4329c0c0014bc5c42276bba065c7bfda21b3f1056d0993530ff19b11485c34a72c75c85f6dea04798568985e81b73a7ba2fc6f91745ad4a3c847
7
+ data.tar.gz: b21814309b97237dde61f86312881a91d645a7fa873e1d4dbc5c14c1a7d28df17215180296f5288612451df904a47e3171af4d4564e0ec34c45151cf5cc3a432
data/README.md CHANGED
@@ -34,9 +34,13 @@ A fast XML parser and Object marshaller as a Ruby gem.
34
34
 
35
35
  ## <a name="release">Release Notes</a>
36
36
 
37
- ### Release 2.0.5
37
+ ### Release 2.0.6
38
38
 
39
- - Better support for special character encoding with 1.8.7.
39
+ - Fixed bug in special character decoding that chopped of text.
40
+
41
+ - Limit depth on dump to 1000 to avoid core dump on circular references if the user does not specify circular.
42
+
43
+ - Handles dumping non-string values for attributes correctly by converting the value to a string.
40
44
 
41
45
  ## <a name="description">Description</a>
42
46
 
@@ -39,6 +39,7 @@
39
39
  #include "ox.h"
40
40
 
41
41
  #define USE_B64 0
42
+ #define MAX_DEPTH 1000
42
43
 
43
44
  typedef unsigned long ulong;
44
45
 
@@ -74,13 +75,13 @@ typedef struct _Out {
74
75
  static void dump_obj_to_xml(VALUE obj, Options copts, Out out);
75
76
 
76
77
  static void dump_first_obj(VALUE obj, Out out);
77
- static void dump_obj(ID aid, VALUE obj, unsigned int depth, Out out);
78
- static void dump_gen_doc(VALUE obj, unsigned int depth, Out out);
79
- static void dump_gen_element(VALUE obj, unsigned int depth, Out out);
80
- static void dump_gen_instruct(VALUE obj, unsigned int depth, Out out);
78
+ static void dump_obj(ID aid, VALUE obj, int depth, Out out);
79
+ static void dump_gen_doc(VALUE obj, int depth, Out out);
80
+ static void dump_gen_element(VALUE obj, int depth, Out out);
81
+ static void dump_gen_instruct(VALUE obj, int depth, Out out);
81
82
  static int dump_gen_attr(VALUE key, VALUE value, Out out);
82
- static int dump_gen_nodes(VALUE obj, unsigned int depth, Out out);
83
- static void dump_gen_val_node(VALUE obj, unsigned int depth,
83
+ static int dump_gen_nodes(VALUE obj, int depth, Out out);
84
+ static void dump_gen_val_node(VALUE obj, int depth,
84
85
  const char *pre, size_t plen,
85
86
  const char *suf, size_t slen, Out out);
86
87
 
@@ -102,7 +103,7 @@ static int is_xml_friendly(const uchar *str, int len);
102
103
 
103
104
  static const char hex_chars[17] = "0123456789abcdef";
104
105
 
105
- static char xml_friendly_chars[256] = "\
106
+ static char xml_friendly_chars[257] = "\
106
107
  88888888811881888888888888888888\
107
108
  11611156111111111111111111114141\
108
109
  11111111111111111111111111111111\
@@ -553,12 +554,15 @@ dump_first_obj(VALUE obj, Out out) {
553
554
  }
554
555
 
555
556
  static void
556
- dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
557
+ dump_obj(ID aid, VALUE obj, int depth, Out out) {
557
558
  struct _Element e;
558
559
  VALUE prev_obj = out->obj;
559
560
  char value_buf[64];
560
561
  int cnt;
561
562
 
563
+ if (MAX_DEPTH < depth) {
564
+ rb_raise(rb_eSysStackError, "maximum depth exceeded");
565
+ }
562
566
  out->obj = obj;
563
567
  if (0 == aid) {
564
568
  /*e.attr.str = 0; */
@@ -985,7 +989,7 @@ dump_hash(VALUE key, VALUE value, Out out) {
985
989
  }
986
990
 
987
991
  static void
988
- dump_gen_doc(VALUE obj, unsigned int depth, Out out) {
992
+ dump_gen_doc(VALUE obj, int depth, Out out) {
989
993
  VALUE attrs = rb_attr_get(obj, ox_attributes_id);
990
994
  VALUE nodes = rb_attr_get(obj, ox_nodes_id);
991
995
 
@@ -1018,7 +1022,7 @@ dump_gen_doc(VALUE obj, unsigned int depth, Out out) {
1018
1022
  }
1019
1023
 
1020
1024
  static void
1021
- dump_gen_element(VALUE obj, unsigned int depth, Out out) {
1025
+ dump_gen_element(VALUE obj, int depth, Out out) {
1022
1026
  VALUE rname = rb_attr_get(obj, ox_at_value_id);
1023
1027
  VALUE attrs = rb_attr_get(obj, ox_attributes_id);
1024
1028
  VALUE nodes = rb_attr_get(obj, ox_nodes_id);
@@ -1066,7 +1070,7 @@ dump_gen_element(VALUE obj, unsigned int depth, Out out) {
1066
1070
  }
1067
1071
 
1068
1072
  static void
1069
- dump_gen_instruct(VALUE obj, unsigned int depth, Out out) {
1073
+ dump_gen_instruct(VALUE obj, int depth, Out out) {
1070
1074
  VALUE rname = rb_attr_get(obj, ox_at_value_id);
1071
1075
  VALUE attrs = rb_attr_get(obj, ox_attributes_id);
1072
1076
  VALUE rcontent = rb_attr_get(obj, ox_at_content_id);
@@ -1100,7 +1104,7 @@ dump_gen_instruct(VALUE obj, unsigned int depth, Out out) {
1100
1104
  }
1101
1105
 
1102
1106
  static int
1103
- dump_gen_nodes(VALUE obj, unsigned int depth, Out out) {
1107
+ dump_gen_nodes(VALUE obj, int depth, Out out) {
1104
1108
  long cnt = RARRAY_LEN(obj);
1105
1109
  int indent_needed = 1;
1106
1110
 
@@ -1109,6 +1113,9 @@ dump_gen_nodes(VALUE obj, unsigned int depth, Out out) {
1109
1113
  VALUE clas;
1110
1114
  int d2 = depth + 1;
1111
1115
 
1116
+ if (MAX_DEPTH < depth) {
1117
+ rb_raise(rb_eSysStackError, "maximum depth exceeded");
1118
+ }
1112
1119
  for (; 0 < cnt; cnt--, np++) {
1113
1120
  clas = rb_obj_class(*np);
1114
1121
  if (ox_element_clas == clas) {
@@ -1135,16 +1142,31 @@ dump_gen_nodes(VALUE obj, unsigned int depth, Out out) {
1135
1142
 
1136
1143
  static int
1137
1144
  dump_gen_attr(VALUE key, VALUE value, Out out) {
1145
+ const char *ks;
1146
+ size_t klen;
1147
+ size_t size;
1148
+
1138
1149
  #if HAS_PRIVATE_ENCODING
1139
1150
  // There seems to be a bug in jruby for converting symbols to strings and preserving the encoding. This is a work
1140
1151
  // around.
1141
- const char *ks = rb_str_ptr(rb_String(key));
1152
+ ks = rb_str_ptr(rb_String(key));
1142
1153
  #else
1143
- const char *ks = (T_SYMBOL == rb_type(key)) ? rb_id2name(SYM2ID(key)) : StringValuePtr(key);
1154
+ switch (rb_type(key)) {
1155
+ case T_SYMBOL:
1156
+ ks = rb_id2name(SYM2ID(key));
1157
+ break;
1158
+ case T_STRING:
1159
+ ks = StringValuePtr(key);
1160
+ break;
1161
+ default:
1162
+ key = rb_String(key);
1163
+ ks = StringValuePtr(key);
1164
+ break;
1165
+ }
1144
1166
  #endif
1145
- size_t klen = strlen(ks);
1146
- size_t size = 4 + klen + RSTRING_LEN(value);
1147
-
1167
+ klen = strlen(ks);
1168
+ value = rb_String(value);
1169
+ size = 4 + klen + RSTRING_LEN(value);
1148
1170
  if (out->end - out->cur <= (long)size) {
1149
1171
  grow(out, size);
1150
1172
  }
@@ -1159,7 +1181,7 @@ dump_gen_attr(VALUE key, VALUE value, Out out) {
1159
1181
  }
1160
1182
 
1161
1183
  static void
1162
- dump_gen_val_node(VALUE obj, unsigned int depth,
1184
+ dump_gen_val_node(VALUE obj, int depth,
1163
1185
  const char *pre, size_t plen,
1164
1186
  const char *suf, size_t slen, Out out) {
1165
1187
  VALUE v = rb_attr_get(obj, ox_at_value_id);
@@ -30,6 +30,7 @@
30
30
 
31
31
  #include <stdlib.h>
32
32
  #include <errno.h>
33
+ #include <stdint.h>
33
34
  #include <stdio.h>
34
35
  #include <string.h>
35
36
 
@@ -1179,7 +1179,6 @@ ox_sax_collapse_special(SaxDrive dr, char *str, int line, int col) {
1179
1179
  if ('&' == *s) {
1180
1180
  int c = 0;
1181
1181
  char *end;
1182
- //int x = 0;
1183
1182
 
1184
1183
  s++;
1185
1184
  if ('#' == *s) {
@@ -1236,6 +1235,7 @@ ox_sax_collapse_special(SaxDrive dr, char *str, int line, int col) {
1236
1235
  continue;
1237
1236
  }
1238
1237
  s = end + 1;
1238
+ continue;
1239
1239
  } else if (0 == strncasecmp(s, "lt;", 3)) {
1240
1240
  c = '<';
1241
1241
  s += 3;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.0.5'
4
+ VERSION = '2.0.6'
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.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-07-23 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
@@ -90,9 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project: ox
93
- rubygems_version: 2.0.2
93
+ rubygems_version: 2.0.3
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: A fast XML parser and object serializer.
97
97
  test_files: []
98
- has_rdoc: true