sax 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +2 -2
  2. package/lib/sax.js +14 -5
  3. package/package.json +8 -4
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The ISC License
2
2
 
3
- Copyright (c) Isaac Z. Schlueter and Contributors
3
+ Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
@@ -19,7 +19,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
19
  `String.fromCodePoint` by Mathias Bynens used according to terms of MIT
20
20
  License, as follows:
21
21
 
22
- Copyright Mathias Bynens <https://mathiasbynens.be/>
22
+ Copyright (c) 2010-2022 Mathias Bynens <https://mathiasbynens.be/>
23
23
 
24
24
  Permission is hereby granted, free of charge, to any person obtaining
25
25
  a copy of this software and associated documentation files (the
package/lib/sax.js CHANGED
@@ -164,6 +164,7 @@
164
164
  } catch (ex) {
165
165
  Stream = function () {}
166
166
  }
167
+ if (!Stream) Stream = function () {}
167
168
 
168
169
  var streamWraps = sax.EVENTS.filter(function (ev) {
169
170
  return ev !== 'error' && ev !== 'end'
@@ -933,7 +934,7 @@
933
934
  }
934
935
  }
935
936
  entity = entity.replace(/^0+/, '')
936
- if (numStr.toLowerCase() !== entity) {
937
+ if (isNaN(num) || numStr.toLowerCase() !== entity) {
937
938
  strictFail(parser, 'Invalid character entity')
938
939
  return '&' + parser.entity + ';'
939
940
  }
@@ -1482,9 +1483,16 @@
1482
1483
  }
1483
1484
 
1484
1485
  if (c === ';') {
1485
- parser[buffer] += parseEntity(parser)
1486
- parser.entity = ''
1487
- parser.state = returnState
1486
+ if (parser.opt.unparsedEntities) {
1487
+ var parsedEntity = parseEntity(parser)
1488
+ parser.entity = ''
1489
+ parser.state = returnState
1490
+ parser.write(parsedEntity)
1491
+ } else {
1492
+ parser[buffer] += parseEntity(parser)
1493
+ parser.entity = ''
1494
+ parser.state = returnState
1495
+ }
1488
1496
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
1489
1497
  parser.entity += c
1490
1498
  } else {
@@ -1496,8 +1504,9 @@
1496
1504
 
1497
1505
  continue
1498
1506
 
1499
- default:
1507
+ default: /* istanbul ignore next */ {
1500
1508
  throw new Error(parser, 'Unknown state: ' + parser.state)
1509
+ }
1501
1510
  }
1502
1511
  } // while
1503
1512
 
package/package.json CHANGED
@@ -2,12 +2,11 @@
2
2
  "name": "sax",
3
3
  "description": "An evented streaming XML parser in JavaScript",
4
4
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
5
- "version": "1.2.3",
5
+ "version": "1.3.0",
6
6
  "main": "lib/sax.js",
7
7
  "license": "ISC",
8
8
  "scripts": {
9
9
  "test": "tap test/*.js --cov -j4",
10
- "posttest": "standard -F test/*.js lib/*.js",
11
10
  "preversion": "npm test",
12
11
  "postversion": "npm publish",
13
12
  "postpublish": "git push origin --all; git push origin --tags"
@@ -19,7 +18,12 @@
19
18
  "README.md"
20
19
  ],
21
20
  "devDependencies": {
22
- "standard": "^8.6.0",
23
- "tap": "^10.0.2"
21
+ "tap": "^15.1.6"
22
+ },
23
+ "tap": {
24
+ "statements": 79,
25
+ "branches": 75,
26
+ "functions": 80,
27
+ "lines": 79
24
28
  }
25
29
  }