ox 2.4.12 → 2.4.13

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: e3e52f21c5d0c93066ee3ef6df56da85ea9a292c
4
- data.tar.gz: 4f1172ee0271140ac82efe30b725d59c127f2d51
3
+ metadata.gz: 654a73d8f85ba9a01dfd09ff524b7dd81ac806a1
4
+ data.tar.gz: 02c2c54c3a0d7d9b9caaac89d5dd5757f4e9e40f
5
5
  SHA512:
6
- metadata.gz: 0041f24b54d71b7b3b27b1586268c01e244edc869ba9ada9ab86b16e663b989bc6748c8072e657b40afec4978e26b491774c18d0de5027ec54dd0c7f0ea64fe7
7
- data.tar.gz: cf6950e3f7c792ca02e08dbd5d627eb47b9d46fe43c68cc8ceb9c71de761c9d273fd545dea858be17083007a3ee315af0f492bad50dc648f999cc5047a6b94a1
6
+ metadata.gz: e77e791dbe2cad9dd008a19351026dbf0716f338eee3d28a3849c3f835e5803d2471254e1705490de3c4881747360b32d93c5f869a709df9dfc5ec6a914ea7c2
7
+ data.tar.gz: 30c11b784d183ec6dc5ab0465f7aa68207a97dfb6a660f7f626fea1a265082b7733d18bc1ac0589a5e7eb8af0e0463f2c34008bf0bd31fd5a011682df2ce298b
@@ -37,8 +37,9 @@ typedef struct _Builder {
37
37
  static VALUE builder_class = Qundef;
38
38
  static const char indent_spaces[] = "\n "; // 128 spaces
39
39
 
40
- // The : character is equivalent to 10. Used for replacement characters up to 10
41
- // characters long such as ''.
40
+ // The : character is equivalent to 10. Used for replacement characters up to
41
+ // 10 characters long such as ''. From
42
+ // https://www.w3.org/TR/2006/REC-xml11-20060816
42
43
  #if 0
43
44
  static const char xml_friendly_chars[257] = "\
44
45
  :::::::::11::1::::::::::::::::::\
@@ -49,18 +50,21 @@ static const char xml_friendly_chars[257] = "\
49
50
  11111111111111111111111111111111\
50
51
  11111111111111111111111111111111\
51
52
  11111111111111111111111111111111";
53
+ #endif
52
54
 
53
- static const char xml_quote_chars[257] = "\
55
+ // From 2.3 of the XML 1.1 spec. All over 0x20 except <&", > also. Builder
56
+ // uses double quotes for attributes.
57
+ static const char xml_attr_chars[257] = "\
54
58
  :::::::::11::1::::::::::::::::::\
55
- 11611151111111111111111111111111\
59
+ 11611151111111111111111111114141\
56
60
  11111111111111111111111111111111\
57
61
  11111111111111111111111111111111\
58
62
  11111111111111111111111111111111\
59
63
  11111111111111111111111111111111\
60
64
  11111111111111111111111111111111\
61
65
  11111111111111111111111111111111";
62
- #endif
63
66
 
67
+ // From 3.1 of the XML 1.1 spec. All over 0x20 except <&, > also.
64
68
  static const char xml_element_chars[257] = "\
65
69
  :::::::::11::1::::::::::::::::::\
66
70
  11111151111111111111111111114141\
@@ -222,8 +226,7 @@ append_attr(VALUE key, VALUE value, Builder b) {
222
226
  b->col += 2;
223
227
  b->pos += 2;
224
228
  Check_Type(value, T_STRING);
225
- //append_string(b, StringValuePtr(value), (int)RSTRING_LEN(value), xml_quote_chars);
226
- append_string(b, StringValuePtr(value), (int)RSTRING_LEN(value), xml_element_chars);
229
+ append_string(b, StringValuePtr(value), (int)RSTRING_LEN(value), xml_attr_chars);
227
230
  buf_append(&b->buf, '"');
228
231
  b->col++;
229
232
  b->pos++;
@@ -854,9 +857,6 @@ builder_close(VALUE self) {
854
857
  * An XML builder.
855
858
  */
856
859
  void ox_init_builder(VALUE ox) {
857
- #if 0
858
- ox = rb_define_module("Ox");
859
- #endif
860
860
  builder_class = rb_define_class_under(ox, "Builder", rb_cObject);
861
861
  rb_define_module_function(builder_class, "new", builder_new, -1);
862
862
  rb_define_module_function(builder_class, "file", builder_file, -1);
@@ -9,6 +9,7 @@
9
9
  #include <string.h>
10
10
  #include <strings.h>
11
11
  #include <stdarg.h>
12
+ #include <stdint.h>
12
13
 
13
14
  #include "cache.h"
14
15
 
@@ -27,7 +28,7 @@ static char* form_key(const char *s) {
27
28
  size_t len = strlen(s);
28
29
  char *d = ALLOC_N(char, len + 2);
29
30
 
30
- *d = (255 <= len) ? 255 : len;
31
+ *(uint8_t*)d = (255 <= len) ? 255 : len;
31
32
  memcpy(d + 1, s, len + 1);
32
33
 
33
34
  return d;
@@ -1156,6 +1156,28 @@ read_text(SaxDrive dr) {
1156
1156
  int isEnd = ('/' == buf_get(&dr->buf));
1157
1157
 
1158
1158
  buf_backup(&dr->buf);
1159
+ if (NoSkip == dr->options.skip && dr->has.text && !isEnd) {
1160
+ args[0] = rb_str_new2(dr->buf.str);
1161
+ #if HAS_ENCODING_SUPPORT
1162
+ if (0 != dr->encoding) {
1163
+ rb_enc_associate(args[0], dr->encoding);
1164
+ }
1165
+ #elif HAS_PRIVATE_ENCODING
1166
+ if (Qnil != dr->encoding) {
1167
+ rb_funcall(args[0], ox_force_encoding_id, 1, dr->encoding);
1168
+ }
1169
+ #endif
1170
+ if (dr->has.pos) {
1171
+ rb_ivar_set(dr->handler, ox_at_pos_id, LONG2NUM(pos));
1172
+ }
1173
+ if (dr->has.line) {
1174
+ rb_ivar_set(dr->handler, ox_at_line_id, LONG2NUM(line));
1175
+ }
1176
+ if (dr->has.column) {
1177
+ rb_ivar_set(dr->handler, ox_at_column_id, LONG2NUM(col));
1178
+ }
1179
+ rb_funcall2(dr->handler, ox_text_id, 1, args);
1180
+ }
1159
1181
  if (!isEnd || 0 == parent || 0 < parent->childCnt) {
1160
1182
  return c;
1161
1183
  }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.4.12'
4
+ VERSION = '2.4.13'
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.12
4
+ version: 2.4.13
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-11 00:00:00.000000000 Z
11
+ date: 2017-04-21 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