ox 2.14.17 → 2.14.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b849217680d29abfe528da7bd89f0d5b2700f19a28dd09ed176a663f4cd35ab
4
- data.tar.gz: 1a4690fc380ca55710b5ddf1d862503a1e6ef7cdfa9a5ebfb973c9c5b4ed6ea4
3
+ metadata.gz: fd178b1fd415d3a97ef3b60e73896d52fd3eea1e9ef7a32dd0de316e00a21542
4
+ data.tar.gz: f9813bab8a071e6ba9efa07a92c228d3ea783a29503cfc763e72e73220899fe8
5
5
  SHA512:
6
- metadata.gz: 98b13052c1015400d8bbec0f79525562eb6e47e21826ca7c89b9197096ead85701211139be6562e5a72d411a47f75d0bb8c354b9ccc28e9c9eaf05ac897dc8ce
7
- data.tar.gz: 94ea365ef3cd0a40e36d743b15b0d587748f0d26df8fcb1a9d660c431c6179011fc3531dc559bea95ea5f5b3594907b17f5f1369c0ac5f660ad657f21c286a04
6
+ metadata.gz: 1a7cfc1bfbe0693f52f66f662d4f0f8eeabe20bc50ddefb854abde16e1f1e1c8236b64a2c1ebd51d6de18a697f588ff4d60f854e7b50b383db14ad6eed57ae92
7
+ data.tar.gz: ae9344f3607e94721eafda29f7255be6a36a0340dd4de3b03d249e616126ec340f5c9485f855ba342f33c951d7153c1b47e0b95aaada4e1936741f2b6755452c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All changes to the Ox gem are documented here. Releases follow semantic versioning.
4
4
 
5
+ ## [2.14.18] - 2024-03-21
6
+
7
+ ### Fixed
8
+
9
+ - UTF8 element names now load correctly thansk to @Uelb.
10
+
5
11
  ## [2.14.17] - 2023-07-14
6
12
 
7
13
  ### Fixed
data/ext/ox/hash_load.c CHANGED
@@ -93,14 +93,26 @@ static void add_str(PInfo pi, VALUE s) {
93
93
  }
94
94
 
95
95
  static void add_text(PInfo pi, char *text, int closed) {
96
- add_str(pi, rb_str_new2(text));
96
+ VALUE s = rb_str_new2(text);
97
+ if (0 != pi->options->rb_enc) {
98
+ rb_enc_associate(s, pi->options->rb_enc);
99
+ }
100
+ add_str(pi, s);
97
101
  }
98
102
 
99
103
  static void add_cdata(PInfo pi, const char *text, size_t len) {
100
- add_str(pi, rb_str_new(text, len));
104
+ VALUE s = rb_str_new2(text);
105
+ if (0 != pi->options->rb_enc) {
106
+ rb_enc_associate(s, pi->options->rb_enc);
107
+ }
108
+ add_str(pi, s);
101
109
  }
102
110
 
103
111
  static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
112
+ VALUE s = rb_str_new2(ename);
113
+ if (0 != pi->options->rb_enc) {
114
+ rb_enc_associate(s, pi->options->rb_enc);
115
+ }
104
116
  if (helper_stack_empty(&pi->helpers)) {
105
117
  create_top(pi);
106
118
  }
@@ -111,12 +123,14 @@ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren
111
123
  volatile VALUE a;
112
124
 
113
125
  for (; 0 != attrs->name; attrs++) {
126
+ key = rb_str_new2(attrs->name);
127
+ if (0 != pi->options->rb_enc) {
128
+ rb_enc_associate(key, pi->options->rb_enc);
129
+ }
114
130
  if (Qnil != pi->options->attr_key_mod) {
115
- key = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
131
+ key = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, key);
116
132
  } else if (Yes == pi->options->sym_keys) {
117
- key = rb_id2sym(rb_intern(attrs->name));
118
- } else {
119
- key = rb_str_new2(attrs->name);
133
+ key = rb_id2sym(rb_intern_str(key));
120
134
  }
121
135
  val = rb_str_new2(attrs->value);
122
136
  if (0 != pi->options->rb_enc) {
@@ -127,17 +141,21 @@ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren
127
141
  a = rb_ary_new();
128
142
  rb_ary_push(a, h);
129
143
  mark_value(pi, a);
130
- helper_stack_push(&pi->helpers, rb_intern(ename), a, ArrayCode);
144
+ helper_stack_push(&pi->helpers, rb_intern_str(s), a, ArrayCode);
131
145
  } else {
132
- helper_stack_push(&pi->helpers, rb_intern(ename), Qnil, NoCode);
146
+ helper_stack_push(&pi->helpers, rb_intern_str(s), Qnil, NoCode);
133
147
  }
134
148
  }
135
149
 
136
150
  static void add_element_no_attrs(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
151
+ VALUE s = rb_str_new2(ename);
152
+ if (0 != pi->options->rb_enc) {
153
+ rb_enc_associate(s, pi->options->rb_enc);
154
+ }
137
155
  if (helper_stack_empty(&pi->helpers)) {
138
156
  create_top(pi);
139
157
  }
140
- helper_stack_push(&pi->helpers, rb_intern(ename), Qnil, NoCode);
158
+ helper_stack_push(&pi->helpers, rb_intern_str(s), Qnil, NoCode);
141
159
  }
142
160
 
143
161
  static int umark_hash_cb(VALUE key, VALUE value, VALUE x) {
@@ -224,8 +242,22 @@ static void finish(PInfo pi) {
224
242
  xfree(pi->marked);
225
243
  }
226
244
 
245
+ static void set_encoding_from_instruct(PInfo pi, Attr attrs) {
246
+ for (; 0 != attrs->name; attrs++) {
247
+ if (0 == strcmp("encoding", attrs->name)) {
248
+ pi->options->rb_enc = rb_enc_find(attrs->value);
249
+ }
250
+ }
251
+ }
252
+
253
+ static void instruct(PInfo pi, const char *target, Attr attrs, const char *content) {
254
+ if (0 == strcmp("xml", target)) {
255
+ set_encoding_from_instruct(pi, attrs);
256
+ }
257
+ }
258
+
227
259
  struct _parseCallbacks _ox_hash_callbacks = {
228
- NULL,
260
+ instruct,
229
261
  NULL,
230
262
  NULL,
231
263
  NULL,
@@ -238,7 +270,7 @@ struct _parseCallbacks _ox_hash_callbacks = {
238
270
  ParseCallbacks ox_hash_callbacks = &_ox_hash_callbacks;
239
271
 
240
272
  struct _parseCallbacks _ox_hash_cdata_callbacks = {
241
- NULL,
273
+ instruct,
242
274
  NULL,
243
275
  NULL,
244
276
  add_cdata,
@@ -251,7 +283,7 @@ struct _parseCallbacks _ox_hash_cdata_callbacks = {
251
283
  ParseCallbacks ox_hash_cdata_callbacks = &_ox_hash_cdata_callbacks;
252
284
 
253
285
  struct _parseCallbacks _ox_hash_no_attrs_callbacks = {
254
- NULL,
286
+ instruct,
255
287
  NULL,
256
288
  NULL,
257
289
  NULL,
@@ -264,7 +296,7 @@ struct _parseCallbacks _ox_hash_no_attrs_callbacks = {
264
296
  ParseCallbacks ox_hash_no_attrs_callbacks = &_ox_hash_no_attrs_callbacks;
265
297
 
266
298
  struct _parseCallbacks _ox_hash_no_attrs_cdata_callbacks = {
267
- NULL,
299
+ instruct,
268
300
  NULL,
269
301
  NULL,
270
302
  add_cdata,
data/ext/ox/ox.h CHANGED
@@ -146,7 +146,7 @@ struct _pInfo {
146
146
  VALUE *marked;
147
147
  int mark_size; // allocated size
148
148
  int mark_cnt;
149
- char last; // last character read, rarely set
149
+ char last; // last character read, rarely set
150
150
  };
151
151
 
152
152
  extern VALUE ox_parse(char *xml, size_t len, ParseCallbacks pcb, char **endp, Options options, Err err);
data/ext/ox/parse.c CHANGED
@@ -167,7 +167,7 @@ ox_parse(char *xml, size_t len, ParseCallbacks pcb, char **endp, Options options
167
167
  helper_stack_cleanup(&pi.helpers);
168
168
  return Qnil;
169
169
  }
170
- pi.s++; // past <
170
+ pi.s++; // past <
171
171
  switch (*pi.s) {
172
172
  case '?': // processing instruction
173
173
  pi.s++;
data/ext/ox/sax.c CHANGED
@@ -1219,7 +1219,7 @@ static char read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml,
1219
1219
  c = buf_next_non_white(&dr->buf);
1220
1220
  }
1221
1221
  if ('=' != c) {
1222
- // TBD allow in smart mode
1222
+ // TBD allow in smart mode
1223
1223
  if (eq_req) {
1224
1224
  dr->err = 1;
1225
1225
  return c;
@@ -1328,7 +1328,7 @@ static char read_quoted_value(SaxDrive dr, bool inst) {
1328
1328
  dr->buf.str = dr->buf.tail - 1;
1329
1329
  // TBD if smart or html then no error
1330
1330
  if (!(dr->options.smart && ox_hints_html() != dr->options.hints)) {
1331
- ox_sax_drive_error(dr, WRONG_CHAR "attribute value not in quotes");
1331
+ ox_sax_drive_error(dr, WRONG_CHAR "attribute value not in quotes");
1332
1332
  }
1333
1333
  while ('\0' != (c = buf_get(&dr->buf))) {
1334
1334
  switch (c) {
@@ -1341,12 +1341,12 @@ static char read_quoted_value(SaxDrive dr, bool inst) {
1341
1341
  *(dr->buf.tail - 1) = '\0'; /* terminate value */
1342
1342
  // dr->buf.tail is in the correct position, one after the word terminator
1343
1343
  return c;
1344
- case '?': // for instructions
1345
- if (inst) {
1346
- *(dr->buf.tail - 1) = '\0'; /* terminate value */
1347
- return c;
1348
- }
1349
- break;
1344
+ case '?':
1345
+ if (inst) {
1346
+ *(dr->buf.tail - 1) = '\0'; /* terminate value */
1347
+ return c;
1348
+ }
1349
+ break;
1350
1350
  default: break;
1351
1351
  }
1352
1352
  }
data/ext/ox/sax_buf.c CHANGED
@@ -79,7 +79,7 @@ int ox_sax_buf_read(Buf buf) {
79
79
  } else {
80
80
  shift = buf->pro - buf->head - 1; // leave one character so we cab backup one
81
81
  }
82
- if (0 >= shift) { /* no space left so allocate more */
82
+ if (0 >= shift) { /* no space left so allocate more */
83
83
  char *old = buf->head;
84
84
  size_t size = buf->end - buf->head + BUF_PAD;
85
85
 
data/ext/ox/slotcache.c CHANGED
@@ -82,8 +82,8 @@ slot_cache_get(SlotCache cache, const char *key, VALUE **slot, const char **keyp
82
82
  orig->key = form_key(key);
83
83
  orig->value = Qundef;
84
84
  }
85
- } else { /* not exact match but on the path */
86
- if (0 != cache->key) { /* there is a key/value here already */
85
+ } else { /* not exact match but on the path */
86
+ if (0 != cache->key) { /* there is a key/value here already */
87
87
  if (depth == *cache->key || (255 <= depth && 0 == strncmp(cache->key, key, depth) &&
88
88
  '\0' == cache->key[depth])) { /* key belongs here */
89
89
  continue;
data/lib/ox/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Ox
2
2
  # Current version of the module.
3
- VERSION = '2.14.17'
3
+ VERSION = '2.14.18'
4
4
  end
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.17
4
+ version: 2.14.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-14 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake-compiler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.2'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2.0'
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
+ dependencies: []
33
13
  description: "A fast XML parser and object serializer that uses only standard C lib.\n\nOptimized
34
14
  XML (Ox), as the name implies was written to provide speed optimized\nXML handling.
35
15
  It was designed to be an alternative to Nokogiri and other Ruby\nXML parsers for
@@ -125,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
105
  - !ruby/object:Gem::Version
126
106
  version: '0'
127
107
  requirements: []
128
- rubygems_version: 3.4.1
108
+ rubygems_version: 3.4.10
129
109
  signing_key:
130
110
  specification_version: 4
131
111
  summary: A fast XML parser and object serializer.