ox 2.4.13 → 2.5.0

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: 654a73d8f85ba9a01dfd09ff524b7dd81ac806a1
4
- data.tar.gz: 02c2c54c3a0d7d9b9caaac89d5dd5757f4e9e40f
3
+ metadata.gz: a240f481e8317d54737d2fcf65fa2f261430637f
4
+ data.tar.gz: 24a418d12d8d84e7a12babc7ca2343d3a082fe72
5
5
  SHA512:
6
- metadata.gz: e77e791dbe2cad9dd008a19351026dbf0716f338eee3d28a3849c3f835e5803d2471254e1705490de3c4881747360b32d93c5f869a709df9dfc5ec6a914ea7c2
7
- data.tar.gz: 30c11b784d183ec6dc5ab0465f7aa68207a97dfb6a660f7f626fea1a265082b7733d18bc1ac0589a5e7eb8af0e0463f2c34008bf0bd31fd5a011682df2ce298b
6
+ metadata.gz: 101806359fe3900f9282358a20f86a3337e5682f0f10b5145b5f2244017f4a162decc38c822cd74eb943de3b9b6c76457067484a405bb5cd95dbf88350aad376
7
+ data.tar.gz: 273adc992eb8cf8093d49dafb25c9af875d99b363c5290a0dec14bf4c3cf4b1fdb1c681893fecb7a062b3cf55f3e8406a359e437f5e79b27b8694a652fac98e4
data/README.md CHANGED
@@ -6,7 +6,7 @@ A fast XML parser and Object marshaller as a Ruby gem.
6
6
 
7
7
  ## Documentation
8
8
 
9
- *Documentation*: http://www.ohler.com/ox
9
+ *Documentation*: http://www.ohler.com/ox/doc
10
10
 
11
11
  ## Source
12
12
 
@@ -120,6 +120,7 @@ static VALUE invalid_replace_sym;
120
120
  static VALUE limited_sym;
121
121
  static VALUE margin_sym;
122
122
  static VALUE mode_sym;
123
+ static VALUE nest_ok_sym;
123
124
  static VALUE object_sym;
124
125
  static VALUE off_sym;
125
126
  static VALUE opt_format_sym;
@@ -166,7 +167,7 @@ struct _Options ox_default_options = {
166
167
  NoMode, /* mode */
167
168
  StrictEffort, /* effort */
168
169
  Yes, /* sym_keys */
169
- NoSkip, /* skip */
170
+ SpcSkip, /* skip */
170
171
  No, /* smart */
171
172
  1, /* convert_special */
172
173
  No, /* allow_invalid */
@@ -249,6 +250,7 @@ hints_to_overlay(Hints hints) {
249
250
  case BlockOverlay: ov = block_sym; break;
250
251
  case OffOverlay: ov = off_sym; break;
251
252
  case AbortOverlay: ov = abort_sym; break;
253
+ case NestOverlay: ov = nest_ok_sym; break;
252
254
  case ActiveOverlay:
253
255
  default: ov = active_sym; break;
254
256
  }
@@ -279,6 +281,7 @@ hints_to_overlay(Hints hints) {
279
281
  * - _:strip_namespace_ [String|true|false] false or "" results in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
280
282
  * - _:overlay_ [Hash] a Hash of keys that match html element names and values that are one of
281
283
  * - _:active_ - make the normal callback for the element
284
+ * - _:nest_ok_ - active but the nesting check is ignored
282
285
  * - _:inactive_ - do not make the element start, end, or attribute callbacks for this element only
283
286
  * - _:block_ - block this and all children callbacks
284
287
  * - _:off_ - block this element and it's children unless the child element is active
@@ -359,6 +362,8 @@ set_overlay(VALUE key, VALUE value, VALUE ctx) {
359
362
  hint->overlay = InactiveOverlay;
360
363
  } else if (block_sym == value) {
361
364
  hint->overlay = BlockOverlay;
365
+ } else if (nest_ok_sym == value) {
366
+ hint->overlay = NestOverlay;
362
367
  } else if (off_sym == value) {
363
368
  hint->overlay = OffOverlay;
364
369
  } else if (abort_sym == value) {
@@ -373,6 +378,7 @@ set_overlay(VALUE key, VALUE value, VALUE ctx) {
373
378
  * Returns an overlay hash that can be modified and used as an overlay in the
374
379
  * default options or in the sax_html() function call. Values for the keys are:
375
380
  * - _:active_ - make the normal callback for the element
381
+ * - _:nest_ok_ - active but ignore nest check
376
382
  * - _:inactive_ - do not make the element start, end, or attribute callbacks for this element only
377
383
  * - _:block_ - block this and all children callbacks
378
384
  * - _:off_ - block this element and it's children unless the child element is active
@@ -407,6 +413,7 @@ sax_html_overlay(VALUE self) {
407
413
  * - _:strip_namespace_ [nil|String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
408
414
  * - _:overlay_ [Hash] a Hash of keys that match html element names and values that are one of
409
415
  * - _:active_ - make the normal callback for the element
416
+ * - _:nest_ok_ - active but ignore nest check
410
417
  * - _:inactive_ - do not make the element start, end, or attribute callbacks for this element only
411
418
  * - _:block_ - block this and all children callbacks
412
419
  * - _:off_ - block this element and it's children unless the child element is active
@@ -965,7 +972,7 @@ load_file(int argc, VALUE *argv, VALUE self) {
965
972
  * - *:convert_special* [true|false] flag indicating special characters like < are converted
966
973
  * - *:symbolize* [true|false] flag indicating the parser symbolize element and attribute names
967
974
  * - *:smart* [true|false] flag indicating the parser uses hints if available (use with html)
968
- * - *:skip* [:skip_return|:skip_white] flag indicating the parser skips \r or collpase white space into a single space. Default (skip nothing)
975
+ * - *:skip* [:skip_return|:skip_white] flag indicating the parser skips \r or collpase white space into a single space. Default (skip space)
969
976
  * - *:strip_namespace* [nil|String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
970
977
  */
971
978
  static VALUE
@@ -1038,9 +1045,10 @@ sax_parse(int argc, VALUE *argv, VALUE self) {
1038
1045
  * - +options+ [Hash] options parse options
1039
1046
  * - *:convert_special* [true|false] flag indicating special characters like < are converted
1040
1047
  * - *:symbolize* [true|false] flag indicating the parser symbolize element and attribute names
1041
- * - *:skip* [:skip_return|:skip_white] flag indicating the parser skips \r or collapse white space into a single space. Default (skip nothing)
1048
+ * - *:skip* [:skip_return|:skip_white] flag indicating the parser skips \r or collapse white space into a single space. Default (skip space)
1042
1049
  * - *:overlay* [Hash] a Hash of keys that match html element names and values that are one of
1043
1050
  * - _:active_ - make the normal callback for the element
1051
+ * - _:nest_ok_ - active but ignore nest check
1044
1052
  * - _:inactive_ - do not make the element start, end, or attribute callbacks for this element only
1045
1053
  * - _:block_ - block this and all children callbacks
1046
1054
  * - _:off_ - block this element and it's children unless the child element is active
@@ -1408,6 +1416,7 @@ void Init_ox() {
1408
1416
  invalid_replace_sym = ID2SYM(rb_intern("invalid_replace")); rb_gc_register_address(&invalid_replace_sym);
1409
1417
  limited_sym = ID2SYM(rb_intern("limited")); rb_gc_register_address(&limited_sym);
1410
1418
  mode_sym = ID2SYM(rb_intern("mode")); rb_gc_register_address(&mode_sym);
1419
+ nest_ok_sym = ID2SYM(rb_intern("nest_ok")); rb_gc_register_address(&nest_ok_sym);
1411
1420
  object_sym = ID2SYM(rb_intern("object")); rb_gc_register_address(&object_sym);
1412
1421
  off_sym = ID2SYM(rb_intern("off")); rb_gc_register_address(&off_sym);
1413
1422
  opt_format_sym = ID2SYM(rb_intern("opt_format")); rb_gc_register_address(&opt_format_sym);
@@ -432,7 +432,8 @@ parse(SaxDrive dr) {
432
432
  for (sp = dr->stack.tail - 1; dr->stack.head <= sp; sp--) {
433
433
  snprintf(msg, sizeof(msg) - 1, "%selement '%s' not closed", EL_MISMATCH, sp->name);
434
434
  ox_sax_drive_error_at(dr, msg, dr->buf.pos, dr->buf.line, dr->buf.col);
435
- if (dr->has.end_element && 0 >= dr->blocked && (NULL == sp->hint || ActiveOverlay == sp->hint->overlay)) {
435
+ if (dr->has.end_element && 0 >= dr->blocked &&
436
+ (NULL == sp->hint || ActiveOverlay == sp->hint->overlay || NestOverlay == sp->hint->overlay)) {
436
437
  VALUE args[1];
437
438
 
438
439
  args[0] = sp->val;
@@ -825,7 +826,7 @@ read_comment(SaxDrive dr) {
825
826
  Hint h = ox_hint_find(dr->options.hints, "!--");
826
827
 
827
828
  if (NULL == parent || NULL == parent->hint || OffOverlay != parent->hint->overlay ||
828
- (NULL != h && ActiveOverlay == h->overlay)) {
829
+ (NULL != h && (ActiveOverlay == h->overlay || ActiveOverlay == h->overlay))) {
829
830
 
830
831
  args[0] = rb_str_new2(dr->buf.str);
831
832
  #if HAS_ENCODING_SUPPORT
@@ -919,8 +920,8 @@ read_element_start(SaxDrive dr) {
919
920
  }
920
921
  if (0 != top_nv) {
921
922
  char msg[256];
922
-
923
- if (!h->nest && 0 == strcasecmp(top_nv->name, h->name)) {
923
+
924
+ if (!h->nest && NestOverlay != h->overlay && 0 == strcasecmp(top_nv->name, h->name)) {
924
925
  snprintf(msg, sizeof(msg) - 1, "%s%s can not be nested in a %s document, closing previous.",
925
926
  INV_ELEMENT, dr->buf.str, dr->options.hints->name);
926
927
  ox_sax_drive_error(dr, msg);
@@ -928,7 +929,7 @@ read_element_start(SaxDrive dr) {
928
929
  end_element_cb(dr, top_nv->val, pos, line, col, top_nv->hint);
929
930
  top_nv = stack_peek(&dr->stack);
930
931
  }
931
- if (0 != h->parents) {
932
+ if (0 != h->parents && NestOverlay != h->overlay) {
932
933
  const char **p;
933
934
  int ok = 0;
934
935
 
@@ -948,7 +949,7 @@ read_element_start(SaxDrive dr) {
948
949
  }
949
950
  }
950
951
  name = str2sym(dr, dr->buf.str, &ename);
951
- if (dr->has.start_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay)) {
952
+ if (dr->has.start_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
952
953
  VALUE args[1];
953
954
 
954
955
  if (dr->has.pos) {
@@ -975,7 +976,7 @@ read_element_start(SaxDrive dr) {
975
976
  }
976
977
  closed = ('/' == c);
977
978
  }
978
- if (dr->has.attrs_done && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay)) {
979
+ if (dr->has.attrs_done && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
979
980
  rb_funcall(dr->handler, ox_attrs_done_id, 0);
980
981
  }
981
982
  if (closed) {
@@ -1060,7 +1061,7 @@ read_element_end(SaxDrive dr) {
1060
1061
  snprintf(msg, sizeof(msg) - 1, "%selement '%s' closed but not opened", EL_MISMATCH, dr->buf.str);
1061
1062
  ox_sax_drive_error_at(dr, msg, pos, line, col);
1062
1063
  name = str2sym(dr, dr->buf.str, 0);
1063
- if (dr->has.start_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay)) {
1064
+ if (dr->has.start_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
1064
1065
  VALUE args[1];
1065
1066
 
1066
1067
  if (dr->has.pos) {
@@ -1099,7 +1100,7 @@ read_element_end(SaxDrive dr) {
1099
1100
  rb_ivar_set(dr->handler, ox_at_column_id, LONG2NUM(col));
1100
1101
  }
1101
1102
  for (nv = stack_pop(&dr->stack); match < nv; nv = stack_pop(&dr->stack)) {
1102
- if (dr->has.end_element && 0 >= dr->blocked && (NULL == nv->hint || ActiveOverlay == nv->hint->overlay)) {
1103
+ if (dr->has.end_element && 0 >= dr->blocked && (NULL == nv->hint || ActiveOverlay == nv->hint->overlay || NestOverlay == h->overlay)) {
1103
1104
  rb_funcall(dr->handler, ox_end_element_id, 1, nv->val);
1104
1105
  }
1105
1106
  if (NULL != nv->hint && BlockOverlay == nv->hint->overlay && 0 < dr->blocked) {
@@ -1387,7 +1388,7 @@ read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml, int eq_req,
1387
1388
  is_encoding = 0;
1388
1389
  }
1389
1390
  }
1390
- if (0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay)) {
1391
+ if (0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
1391
1392
  if (dr->has.attr_value) {
1392
1393
  VALUE args[2];
1393
1394
 
@@ -1732,7 +1733,7 @@ hint_try_close(SaxDrive dr, const char *name) {
1732
1733
 
1733
1734
  static void
1734
1735
  end_element_cb(SaxDrive dr, VALUE name, int pos, int line, int col, Hint h) {
1735
- if (dr->has.end_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay)) {
1736
+ if (dr->has.end_element && 0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
1736
1737
  if (dr->has.pos) {
1737
1738
  rb_ivar_set(dr->handler, ox_at_pos_id, LONG2NUM(pos));
1738
1739
  }
@@ -14,6 +14,7 @@ typedef enum {
14
14
  BlockOverlay = 'b',
15
15
  OffOverlay = 'o',
16
16
  AbortOverlay = 'a',
17
+ NestOverlay = 'n', // nest flag is ignored
17
18
  } Overlay;
18
19
 
19
20
  typedef struct _Hint {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.4.13'
4
+ VERSION = '2.5.0'
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.4.13
4
+ version: 2.5.0
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-04-21 00:00:00.000000000 Z
11
+ date: 2017-05-04 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
@@ -33,7 +33,6 @@ files:
33
33
  - ext/ox/cache8.c
34
34
  - ext/ox/cache8.h
35
35
  - ext/ox/dump.c
36
- - ext/ox/encode.h
37
36
  - ext/ox/err.c
38
37
  - ext/ox/err.h
39
38
  - ext/ox/extconf.rb
@@ -97,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
96
  version: '0'
98
97
  requirements: []
99
98
  rubyforge_project: ox
100
- rubygems_version: 2.6.8
99
+ rubygems_version: 2.6.11
101
100
  signing_key:
102
101
  specification_version: 4
103
102
  summary: A fast XML parser and object serializer.
@@ -1,26 +0,0 @@
1
- /* encode.h
2
- * Copyright (c) 2011, Peter Ohler
3
- * All rights reserved.
4
- */
5
-
6
- #ifndef __OX_ENCODE_H__
7
- #define __OX_ENCODE_H__
8
-
9
- #include "ruby.h"
10
- #if HAS_ENCODING_SUPPORT
11
- #include "ruby/encoding.h"
12
- #endif
13
-
14
- static inline VALUE
15
- ox_encode(VALUE rstr) {
16
- #if HAS_ENCODING_SUPPORT
17
- rb_enc_associate(rstr, ox_utf8_encoding);
18
- #else
19
- if (Qnil != ox_utf8_encoding) {
20
- rstr = rb_funcall(ox_utf8_encoding, ox_iconv_id, 1, rstr);
21
- }
22
- #endif
23
- return rstr;
24
- }
25
-
26
- #endif /* __OX_ENCODE_H__ */