ox 2.2.1 → 2.2.2

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: bec620893f1af26eaf853fec54ac033da9516689
4
- data.tar.gz: 26fd103eb9d31e42ce45bf5371b51740d91d7b21
3
+ metadata.gz: 74bd834772f0b2167d7bd55bc7b98269eade4940
4
+ data.tar.gz: e18e59efd324dc787ceb49cd845383d02ec7924b
5
5
  SHA512:
6
- metadata.gz: 64abf65cab8bd13621831043039a8e4e8ccf7e1bf839bf061a443fb5e9cd7e5d7d6a1334cc36ab5caa9bb71034c03ddcd0f40b0f1d9630920a73be8828230b7c
7
- data.tar.gz: 78332e2f9ef6892242bb8ed4a84a4353a122e8980f660575c719520a83aca5be0d8c6f376b1dd9628b168c7ddc347403c59afd783a175d7fbed6f76be407a2b5
6
+ metadata.gz: 1712ad586c88a18f1ea5b26ecf182dac52303f9534b8ba2f3882c4df85fbddbb25a6ea53867f42d4a39e3f7aca485cecc1e2d65fb814946536ff2285bef6c811
7
+ data.tar.gz: 2aa72647db5c0697b91f7c59247d9005e3882ae47d2cf902f675235cb49706682520fb633b649ad119e9e5f9d50fe331934511e839faf8231abf188f01cfbd54
data/README.md CHANGED
@@ -34,19 +34,17 @@ A fast XML parser and Object marshaller as a Ruby gem.
34
34
 
35
35
  ## Release Notes
36
36
 
37
- ### Current Release 2.2.1
37
+ ### Release 2.2.2
38
38
 
39
- - Added support to handle script elements in html.
40
-
41
- - Added support for position from start for the sax parser.
39
+ - Fixed problem with detecting invalid special character sequences.
42
40
 
43
- ### Release 2.2.0
41
+ - Fixed bug that caused a crash when an <> was encountered with the SAX parser.
44
42
 
45
- - Added the SAX convert_special option to the default options.
43
+ ### Release 2.2.1
46
44
 
47
- - Added the SAX smart option to the default options.
45
+ - Added support to handle script elements in html.
48
46
 
49
- - Other SAX options are now taken from the defaults if not specified.
47
+ - Added support for position from start for the sax parser.
50
48
 
51
49
  ## Description
52
50
 
@@ -106,7 +106,7 @@ ox_cache_get(Cache cache, const char *key, VALUE **slot, const char **keyp) {
106
106
  *slot = &cache->value;
107
107
  if (0 != keyp) {
108
108
  if (0 == cache->key) {
109
- printf("*** Error: failed to set the key for %s\n", key);
109
+ printf("*** Error: failed to set the key for '%s'\n", key);
110
110
  *keyp = 0;
111
111
  } else {
112
112
  *keyp = cache->key + 1;
@@ -1091,6 +1091,8 @@ dump_gen_nodes(VALUE obj, int depth, Out out) {
1091
1091
  indent_needed = (1 == cnt) ? 0 : 1;
1092
1092
  } else if (ox_comment_clas == clas) {
1093
1093
  dump_gen_val_node(*np, d2, "<!-- ", 5, " -->", 4, out);
1094
+ } else if (ox_raw_clas == clas) {
1095
+ dump_gen_val_node(*np, d2, "", 0, "", 0, out);
1094
1096
  } else if (ox_cdata_clas == clas) {
1095
1097
  dump_gen_val_node(*np, d2, "<![CDATA[", 9, "]]>", 3, out);
1096
1098
  } else if (ox_doctype_clas == clas) {
@@ -84,6 +84,7 @@ VALUE ox_bag_clas;
84
84
  VALUE ox_bigdecimal_class;
85
85
  VALUE ox_cdata_clas;
86
86
  VALUE ox_comment_clas;
87
+ VALUE ox_raw_clas;
87
88
  VALUE ox_date_class;
88
89
  VALUE ox_doctype_clas;
89
90
  VALUE ox_document_clas;
@@ -1012,6 +1013,7 @@ void Init_ox() {
1012
1013
  ox_element_clas = rb_const_get_at(Ox, rb_intern("Element"));
1013
1014
  ox_instruct_clas = rb_const_get_at(Ox, rb_intern("Instruct"));
1014
1015
  ox_comment_clas = rb_const_get_at(Ox, rb_intern("Comment"));
1016
+ ox_raw_clas = rb_const_get_at(Ox, rb_intern("Raw"));
1015
1017
  ox_doctype_clas = rb_const_get_at(Ox, rb_intern("DocType"));
1016
1018
  ox_cdata_clas = rb_const_get_at(Ox, rb_intern("CData"));
1017
1019
  ox_bag_clas = rb_const_get_at(Ox, rb_intern("Bag"));
@@ -239,6 +239,7 @@ extern VALUE ox_element_clas;
239
239
  extern VALUE ox_instruct_clas;
240
240
  extern VALUE ox_bag_clas;
241
241
  extern VALUE ox_comment_clas;
242
+ extern VALUE ox_raw_clas;
242
243
  extern VALUE ox_doctype_clas;
243
244
  extern VALUE ox_cdata_clas;
244
245
 
@@ -486,9 +486,8 @@ read_element(PInfo pi) {
486
486
  return 0;
487
487
  }
488
488
  if (0 != strchr(attr_value, '&')) {
489
- if (0 != collapse_special(pi, (char*)attr_value)) {
489
+ if (0 != collapse_special(pi, (char*)attr_value) || err_has(&pi->err)) {
490
490
  attr_stack_cleanup(&attrs);
491
- set_error(&pi->err, "invalid format, special character does not end with a semicolon", pi->str, pi->s);
492
491
  return 0;
493
492
  }
494
493
  }
@@ -1079,10 +1078,13 @@ collapse_special(PInfo pi, char *str) {
1079
1078
  c = '?';
1080
1079
  while (';' != *s++) {
1081
1080
  if ('\0' == *s) {
1081
+ set_error(&pi->err, "Invalid format, special character does not end with a semicolon", pi->str, pi->s);
1082
1082
  return EDOM;
1083
1083
  }
1084
1084
  }
1085
1085
  s++;
1086
+ set_error(&pi->err, "Invalid format, invalid special character sequence", pi->str, pi->s);
1087
+ return 0;
1086
1088
  }
1087
1089
  *b++ = (char)c;
1088
1090
  }
@@ -288,6 +288,7 @@ parse(SaxDrive dr) {
288
288
  c = buf_get(&dr->buf);
289
289
  if ('\0' == c) {
290
290
  ox_sax_drive_error(dr, NO_TERM "DOCTYPE or comment not terminated");
291
+
291
292
  goto DONE;
292
293
  } else if ('-' == c) {
293
294
  c = buf_get(&dr->buf); /* skip first - and get next character */
@@ -850,6 +851,14 @@ read_element_start(SaxDrive dr) {
850
851
  if ('\0' == (c = read_name_token(dr))) {
851
852
  return '\0';
852
853
  }
854
+ if ('\0' == *dr->buf.str) {
855
+ char msg[256];
856
+
857
+ snprintf(msg, sizeof(msg) - 1, "%sempty element", INVALID_FORMAT);
858
+ ox_sax_drive_error_at(dr, msg, pos, line, col);
859
+
860
+ return '\0';
861
+ }
853
862
  if (0 != parent) {
854
863
  parent->childCnt++;
855
864
  }
@@ -1571,7 +1580,7 @@ ox_sax_collapse_special(SaxDrive dr, char *str, int pos, int line, int col) {
1571
1580
  c = '\'';
1572
1581
  s += 5;
1573
1582
  } else {
1574
- ox_sax_drive_error_at(dr, NO_TERM "special character does not end with a semicolon", pos, line, col);
1583
+ ox_sax_drive_error_at(dr, INVALID_FORMAT "Invalid special character sequence", pos, line, col);
1575
1584
  c = '&';
1576
1585
  }
1577
1586
  *b++ = (char)c;
data/lib/ox.rb CHANGED
@@ -66,6 +66,7 @@ require 'ox/error'
66
66
  require 'ox/hasattrs'
67
67
  require 'ox/node'
68
68
  require 'ox/comment'
69
+ require 'ox/raw'
69
70
  require 'ox/instruct'
70
71
  require 'ox/cdata'
71
72
  require 'ox/doctype'
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Ox
3
- # Coments represent XML comments in an XML document. A comment as value
3
+ # Comments represent XML comments in an XML document. A comment has a value
4
4
  # attribute only.
5
5
  class Comment < Node
6
6
  # Creates a new Comment with the specified value.
@@ -0,0 +1,14 @@
1
+
2
+ module Ox
3
+ # Raw elements are used to inject existing XML strings into a document
4
+ # WARNING: Use of this feature can result in invalid XML, since `value` is
5
+ # injected as-is.
6
+ class Raw < Node
7
+ # Creates a new Raw element with the specified value.
8
+ # @param value [String] string value for the comment
9
+ def initialize(value)
10
+ super
11
+ end
12
+
13
+ end # Raw
14
+ end # Ox
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.2.1'
4
+ VERSION = '2.2.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.2.1
4
+ version: 2.2.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: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-10-19 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
@@ -66,6 +66,7 @@ files:
66
66
  - lib/ox/hasattrs.rb
67
67
  - lib/ox/instruct.rb
68
68
  - lib/ox/node.rb
69
+ - lib/ox/raw.rb
69
70
  - lib/ox/sax.rb
70
71
  - lib/ox/version.rb
71
72
  - lib/ox/xmlrpc_adapter.rb
@@ -97,3 +98,4 @@ signing_key:
97
98
  specification_version: 4
98
99
  summary: A fast XML parser and object serializer.
99
100
  test_files: []
101
+ has_rdoc: true