ox 2.2.2 → 2.2.3
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 +4 -4
- data/README.md +6 -8
- data/ext/ox/dump.c +6 -1
- data/ext/ox/extconf.rb +1 -0
- data/ext/ox/ox.c +17 -4
- data/ext/ox/ox.h +1 -1
- data/ext/ox/parse.c +1 -1
- data/ext/ox/sax.c +7 -1
- data/lib/ox/element.rb +1 -0
- data/lib/ox/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: 6501b4bbce82df3807ef682abd7900ad0a01c8c4
|
4
|
+
data.tar.gz: ab7dc1b9321f2f023edba54e29104a3962136b5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0192af23950c8fbcbc3ff351a12b17e57198836e34fe1b8662f4089b93389ac6e2b614deb8c1c96f61c5d99d76aa06509e0a049e97011ea708fc09440df3968
|
7
|
+
data.tar.gz: b95bb36a7fbc7695dcb333f13e610d9086e977a538c22e85c1941fb33d076c9b371380a208d4ed5f078556a73bae4c36cd895e2615b254bb987aa4b3837b7483
|
data/README.md
CHANGED
@@ -34,17 +34,15 @@ A fast XML parser and Object marshaller as a Ruby gem.
|
|
34
34
|
|
35
35
|
## Release Notes
|
36
36
|
|
37
|
-
### Release 2.2.
|
37
|
+
### Release 2.2.3
|
38
38
|
|
39
|
-
-
|
39
|
+
- The convert_special option now applies to attributes as well as elements in
|
40
|
+
the SAX parser.
|
40
41
|
|
41
|
-
-
|
42
|
+
- The convert_special option now applies to the regualr parser as well as the
|
43
|
+
SAX parser.
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
- Added support to handle script elements in html.
|
46
|
-
|
47
|
-
- Added support for position from start for the sax parser.
|
45
|
+
- Updated to work correctly with Ruby 2.3.0.
|
48
46
|
|
49
47
|
## Description
|
50
48
|
|
data/ext/ox/dump.c
CHANGED
@@ -540,10 +540,15 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
540
540
|
}
|
541
541
|
out->obj = obj;
|
542
542
|
if (0 == aid) {
|
543
|
-
|
543
|
+
e.attr.str = 0;
|
544
544
|
e.attr.len = 0;
|
545
545
|
} else {
|
546
546
|
e.attr.str = rb_id2name(aid);
|
547
|
+
// Ruby 2.3 started to return NULL for some IDs so check for
|
548
|
+
// NULL. Ignore is NULL aid.
|
549
|
+
if (NULL == e.attr.str) {
|
550
|
+
return;
|
551
|
+
}
|
547
552
|
e.attr.len = strlen(e.attr.str);
|
548
553
|
}
|
549
554
|
e.closed = 0;
|
data/ext/ox/extconf.rb
CHANGED
@@ -35,6 +35,7 @@ dflags = {
|
|
35
35
|
'HAS_BIGDECIMAL' => ('jruby' != type) ? 1 : 0,
|
36
36
|
'HAS_TOP_LEVEL_ST_H' => ('ree' == type || ('ruby' == type && '1' == version[0] && '8' == version[1])) ? 1 : 0,
|
37
37
|
'NEEDS_UIO' => (RUBY_PLATFORM =~ /(win|w)32$/) ? 0 : 1,
|
38
|
+
'HAS_DATA_OBJECT_WRAP' => ('ruby' == type && '2' == version[0] && '3' <= version[1]) ? 1 : 0,
|
38
39
|
}
|
39
40
|
|
40
41
|
if RUBY_PLATFORM =~ /(win|w)32$/ || RUBY_PLATFORM =~ /solaris2\.10/
|
data/ext/ox/ox.c
CHANGED
@@ -148,7 +148,7 @@ struct _Options ox_default_options = {
|
|
148
148
|
Yes, /* sym_keys */
|
149
149
|
NoSkip, /* skip */
|
150
150
|
No, /* smart */
|
151
|
-
|
151
|
+
1, /* convert_special */
|
152
152
|
#if HAS_PRIVATE_ENCODING
|
153
153
|
Qnil /* rb_enc */
|
154
154
|
#else
|
@@ -249,7 +249,7 @@ get_def_opts(VALUE self) {
|
|
249
249
|
rb_hash_aset(opts, xsd_date_sym, (Yes == ox_default_options.xsd_date) ? Qtrue : ((No == ox_default_options.xsd_date) ? Qfalse : Qnil));
|
250
250
|
rb_hash_aset(opts, symbolize_keys_sym, (Yes == ox_default_options.sym_keys) ? Qtrue : ((No == ox_default_options.sym_keys) ? Qfalse : Qnil));
|
251
251
|
rb_hash_aset(opts, smart_sym, (Yes == ox_default_options.smart) ? Qtrue : ((No == ox_default_options.smart) ? Qfalse : Qnil));
|
252
|
-
rb_hash_aset(opts, convert_special_sym, (
|
252
|
+
rb_hash_aset(opts, convert_special_sym, (ox_default_options.convert_special) ? Qtrue : Qfalse);
|
253
253
|
switch (ox_default_options.mode) {
|
254
254
|
case ObjMode: rb_hash_aset(opts, mode_sym, object_sym); break;
|
255
255
|
case GenMode: rb_hash_aset(opts, mode_sym, generic_sym); break;
|
@@ -301,7 +301,6 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
301
301
|
{ circular_sym, &ox_default_options.circular },
|
302
302
|
{ symbolize_keys_sym, &ox_default_options.sym_keys },
|
303
303
|
{ smart_sym, &ox_default_options.smart },
|
304
|
-
{ convert_special_sym, &ox_default_options.convert_special },
|
305
304
|
{ Qnil, 0 }
|
306
305
|
};
|
307
306
|
YesNoOpt o;
|
@@ -374,6 +373,17 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
374
373
|
rb_raise(ox_parse_error_class, ":skip must be :skip_none, :skip_return, :skip_white, or nil.\n");
|
375
374
|
}
|
376
375
|
|
376
|
+
v = rb_hash_lookup(opts, convert_special_sym);
|
377
|
+
if (Qnil == v) {
|
378
|
+
// no change
|
379
|
+
} else if (Qtrue == v) {
|
380
|
+
ox_default_options.convert_special = 1;
|
381
|
+
} else if (Qfalse == v) {
|
382
|
+
ox_default_options.convert_special = 0;
|
383
|
+
} else {
|
384
|
+
rb_raise(ox_parse_error_class, ":convert_special must be true or false.\n");
|
385
|
+
}
|
386
|
+
|
377
387
|
for (o = ynos; 0 != o->attr; o++) {
|
378
388
|
v = rb_hash_lookup(opts, o->sym);
|
379
389
|
if (Qnil == v) {
|
@@ -523,6 +533,9 @@ load(char *xml, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
|
|
523
533
|
if (Qnil != (v = rb_hash_lookup(h, symbolize_keys_sym))) {
|
524
534
|
options.sym_keys = (Qfalse == v) ? No : Yes;
|
525
535
|
}
|
536
|
+
if (Qnil != (v = rb_hash_lookup(h, convert_special_sym))) {
|
537
|
+
options.convert_special = (Qfalse != v);
|
538
|
+
}
|
526
539
|
}
|
527
540
|
#if HAS_ENCODING_SUPPORT
|
528
541
|
if ('\0' == *options.encoding) {
|
@@ -706,7 +719,7 @@ sax_parse(int argc, VALUE *argv, VALUE self) {
|
|
706
719
|
struct _SaxOptions options;
|
707
720
|
|
708
721
|
options.symbolize = (No != ox_default_options.sym_keys);
|
709
|
-
options.convert_special =
|
722
|
+
options.convert_special = ox_default_options.convert_special;
|
710
723
|
options.smart = (Yes == ox_default_options.smart);
|
711
724
|
options.skip = ox_default_options.skip;
|
712
725
|
|
data/ext/ox/ox.h
CHANGED
@@ -132,7 +132,7 @@ typedef struct _Options {
|
|
132
132
|
char sym_keys; /* symbolize keys */
|
133
133
|
char skip; /* skip mode */
|
134
134
|
char smart; /* YesNo sax smart mode */
|
135
|
-
char convert_special;/*
|
135
|
+
char convert_special;/* boolean true or false */
|
136
136
|
#if HAS_ENCODING_SUPPORT
|
137
137
|
rb_encoding *rb_enc;
|
138
138
|
#elif HAS_PRIVATE_ENCODING
|
data/ext/ox/parse.c
CHANGED
@@ -485,7 +485,7 @@ read_element(PInfo pi) {
|
|
485
485
|
if (0 == (attr_value = read_quoted_value(pi))) {
|
486
486
|
return 0;
|
487
487
|
}
|
488
|
-
if (0 != strchr(attr_value, '&')) {
|
488
|
+
if (pi->options->convert_special && 0 != strchr(attr_value, '&')) {
|
489
489
|
if (0 != collapse_special(pi, (char*)attr_value) || err_has(&pi->err)) {
|
490
490
|
attr_stack_cleanup(&attrs);
|
491
491
|
return 0;
|
data/ext/ox/sax.c
CHANGED
@@ -174,7 +174,11 @@ sax_drive_init(SaxDrive dr, VALUE handler, VALUE io, SaxOptions options) {
|
|
174
174
|
dr->buf.dr = dr;
|
175
175
|
stack_init(&dr->stack);
|
176
176
|
dr->handler = handler;
|
177
|
+
#if HAS_DATA_OBJECT_WRAP
|
178
|
+
dr->value_obj = rb_data_object_wrap(ox_sax_value_class, dr, 0, 0);
|
179
|
+
#else
|
177
180
|
dr->value_obj = rb_data_object_alloc(ox_sax_value_class, dr, 0, 0);
|
181
|
+
#endif
|
178
182
|
rb_gc_register_address(&dr->value_obj);
|
179
183
|
dr->options = *options;
|
180
184
|
dr->hints = 0;
|
@@ -1333,7 +1337,9 @@ read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml, int eq_req)
|
|
1333
1337
|
VALUE args[2];
|
1334
1338
|
|
1335
1339
|
args[0] = name;
|
1336
|
-
|
1340
|
+
if (dr->options.convert_special) {
|
1341
|
+
ox_sax_collapse_special(dr, dr->buf.str, pos, line, col);
|
1342
|
+
}
|
1337
1343
|
args[1] = rb_str_new2(attr_value);
|
1338
1344
|
#if HAS_ENCODING_SUPPORT
|
1339
1345
|
if (0 != dr->encoding) {
|
data/lib/ox/element.rb
CHANGED
data/lib/ox/version.rb
CHANGED
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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-31 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
|