ox 2.14.8 → 2.14.9

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: 141360789b82c7bdc927d64818b673c91f2c0ca585c9d00eab8f81324c5b56e2
4
- data.tar.gz: 0b19c86cce35dcc00c4da5b526722580eedcb7dd5edce9eb96ccd99407f4ca84
3
+ metadata.gz: a3cc19bc7d94f71b8e8252f3b22475383d3700b2cfe7f3e97aeaff4c36dc4730
4
+ data.tar.gz: 0034552f9848f7215d7533066d5a971c59dbfd1526257b479512489fe30e371b
5
5
  SHA512:
6
- metadata.gz: cbfe081ac34c6fbea4719156f0666d9554d2c25b23e52546c95cc5fbae89105dfe1aef0c6b5ad659bea540bbcf6bd87b4ea661d9e82fdd3798db6f41eecb3bcd
7
- data.tar.gz: a7946c2929b553b5c019dc5ee43a07fb289aa7e5f93ae3ad890862f018310efb5fa172822944a2be5178f88884d6404daa0d7bdc9dd8b733e1a8a55547909ca8
6
+ metadata.gz: b6ea9d757870451eaf28771481fe703ade50de9dc85d91575545be65ba0a65d7a71a4d193684130725ccad58ad506e1b47fd241aef92950c619be7d49779cbef
7
+ data.tar.gz: cdd97b3ee73f8755cc7a4296c64d41553b03619c7f37f561ad55b958e769e0dc65e652800da0a03b1a9ecb74a17b563188f01a1b8f86fed2d01395ec2eabd587
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.9] - 2022-02-11
6
+
7
+ ### Fixed
8
+
9
+ - Fixed the `\r` replacement with `\n` with the SAX parser according to https://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends.
10
+
5
11
  ## [2.14.8] - 2022-02-09
6
12
 
7
13
  ### Fixed
data/ext/ox/parse.c CHANGED
@@ -108,7 +108,7 @@ static void fix_newlines(char *buf) {
108
108
  if ('\n' == *(s + 1)) {
109
109
  continue;
110
110
  }
111
- *s = '\n';
111
+ *d = '\n';
112
112
  } else if (d < s) {
113
113
  *d = *s;
114
114
  }
data/ext/ox/sax.c CHANGED
@@ -307,8 +307,8 @@ static void sax_drive_init(SaxDrive dr, VALUE handler, VALUE io, SaxOptions opti
307
307
  dr->encoding = rb_enc_find(ox_default_options.encoding);
308
308
  }
309
309
  dr->utf8 = (NULL == dr->encoding || rb_utf8_encoding() == dr->encoding);
310
- if (NULL == dr->encoding || rb_utf8_encoding() == dr->encoding) { // UTF-8
311
- dr->get_name = dr->options.symbolize ? ox_utf8_sym : ox_utf8_name; // TBD UTF8 sym?
310
+ if (NULL == dr->encoding || rb_utf8_encoding() == dr->encoding) { // UTF-8
311
+ dr->get_name = dr->options.symbolize ? ox_utf8_sym : ox_utf8_name; // TBD UTF8 sym?
312
312
  } else {
313
313
  dr->get_name = dr->options.symbolize ? ox_enc_sym : ox_enc_name;
314
314
  }
@@ -334,7 +334,7 @@ static char skipBOM(SaxDrive dr) {
334
334
  if (0xEF == (uint8_t)c) { /* only UTF8 is supported */
335
335
  if (0xBB == (uint8_t)buf_get(&dr->buf) && 0xBF == (uint8_t)buf_get(&dr->buf)) {
336
336
  dr->encoding = ox_utf8_encoding;
337
- c = buf_get(&dr->buf);
337
+ c = buf_get(&dr->buf);
338
338
  } else {
339
339
  ox_sax_drive_error(dr, BAD_BOM "invalid BOM or a binary file.");
340
340
  c = '\0';
@@ -1217,7 +1217,7 @@ static char read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml,
1217
1217
  attr_value = dr->buf.str;
1218
1218
  if (is_encoding) {
1219
1219
  dr->encoding = rb_enc_find(dr->buf.str);
1220
- is_encoding = 0;
1220
+ is_encoding = 0;
1221
1221
  }
1222
1222
  }
1223
1223
  if (0 >= dr->blocked && (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
@@ -1368,7 +1368,8 @@ int ox_sax_collapse_special(SaxDrive dr, char *str, long pos, long line, long co
1368
1368
  char *b = str;
1369
1369
 
1370
1370
  while ('\0' != *s) {
1371
- if ('&' == *s) {
1371
+ switch (*s) {
1372
+ case '&': {
1372
1373
  int c = 0;
1373
1374
  char *end;
1374
1375
 
@@ -1458,13 +1459,25 @@ int ox_sax_collapse_special(SaxDrive dr, char *str, long pos, long line, long co
1458
1459
  }
1459
1460
  *b++ = (char)c;
1460
1461
  col++;
1461
- } else {
1462
+ break;
1463
+ }
1464
+ case '\r':
1465
+ s++;
1462
1466
  if ('\n' == *s) {
1463
- line++;
1464
- col = 0;
1465
- }
1467
+ continue;
1468
+ }
1469
+ line++;
1470
+ col = 1;
1471
+ *b++ = '\n';
1472
+ break;
1473
+ case '\n':
1474
+ line++;
1475
+ col = 0;
1476
+ // fall through
1477
+ default:
1466
1478
  col++;
1467
1479
  *b++ = *s++;
1480
+ break;
1468
1481
  }
1469
1482
  }
1470
1483
  *b = '\0';
data/lib/ox/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.14.8'
4
+ VERSION = '2.14.9'
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.14.8
4
+ version: 2.14.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2022-02-11 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\nOptimized
14
14
  XML (Ox), as the name implies was written to provide speed optimized\nXML handling.