cbor-x 1.6.3 → 1.6.5
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.
- package/decode.js +40 -15
- package/dist/decode-no-eval.cjs +40 -15
- package/dist/decode-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.cjs +40 -15
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +42 -16
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +49 -17
- package/dist/test.js.map +1 -1
- package/package.json +2 -2
package/dist/node.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var stream = require('stream');
|
|
4
4
|
var module$1 = require('module');
|
|
5
5
|
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
7
|
let decoder;
|
|
7
8
|
try {
|
|
8
9
|
decoder = new TextDecoder();
|
|
@@ -600,27 +601,52 @@ function readStringJS(length) {
|
|
|
600
601
|
units.push(byte1);
|
|
601
602
|
} else if ((byte1 & 0xe0) === 0xc0) {
|
|
602
603
|
// 2 bytes
|
|
603
|
-
|
|
604
|
-
|
|
604
|
+
if (byte1 < 0xc2 || position$1 >= end || (src[position$1] & 0xc0) !== 0x80) {
|
|
605
|
+
units.push(0xFFFD);
|
|
606
|
+
} else {
|
|
607
|
+
const byte2 = src[position$1++] & 0x3f;
|
|
608
|
+
units.push(((byte1 & 0x1f) << 6) | byte2);
|
|
609
|
+
}
|
|
605
610
|
} else if ((byte1 & 0xf0) === 0xe0) {
|
|
606
611
|
// 3 bytes
|
|
607
|
-
const byte2 = src[position$1
|
|
608
|
-
|
|
609
|
-
|
|
612
|
+
const byte2 = position$1 < end ? src[position$1] : 0;
|
|
613
|
+
if (position$1 >= end || (byte2 & 0xc0) !== 0x80 ||
|
|
614
|
+
(byte1 === 0xe0 && byte2 < 0xa0) || (byte1 === 0xed && byte2 >= 0xa0)) {
|
|
615
|
+
units.push(0xFFFD);
|
|
616
|
+
} else {
|
|
617
|
+
position$1++;
|
|
618
|
+
if (position$1 >= end || (src[position$1] & 0xc0) !== 0x80) {
|
|
619
|
+
units.push(0xFFFD);
|
|
620
|
+
} else {
|
|
621
|
+
const byte3 = src[position$1++] & 0x3f;
|
|
622
|
+
units.push(((byte1 & 0x1f) << 12) | ((byte2 & 0x3f) << 6) | byte3);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
610
625
|
} else if ((byte1 & 0xf8) === 0xf0) {
|
|
611
626
|
// 4 bytes
|
|
612
|
-
const byte2 = src[position$1
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
627
|
+
const byte2 = position$1 < end ? src[position$1] : 0;
|
|
628
|
+
if (byte1 > 0xf4 || position$1 >= end || (byte2 & 0xc0) !== 0x80 ||
|
|
629
|
+
(byte1 === 0xf0 && byte2 < 0x90) || (byte1 === 0xf4 && byte2 >= 0x90)) {
|
|
630
|
+
units.push(0xFFFD);
|
|
631
|
+
} else {
|
|
632
|
+
position$1++;
|
|
633
|
+
if (position$1 >= end || (src[position$1] & 0xc0) !== 0x80) {
|
|
634
|
+
units.push(0xFFFD);
|
|
635
|
+
} else {
|
|
636
|
+
const byte3 = src[position$1++] & 0x3f;
|
|
637
|
+
if (position$1 >= end || (src[position$1] & 0xc0) !== 0x80) {
|
|
638
|
+
units.push(0xFFFD);
|
|
639
|
+
} else {
|
|
640
|
+
const byte4 = src[position$1++] & 0x3f;
|
|
641
|
+
let unit = ((byte1 & 0x07) << 0x12) | ((byte2 & 0x3f) << 0x0c) | (byte3 << 0x06) | byte4;
|
|
642
|
+
unit -= 0x10000;
|
|
643
|
+
units.push(((unit >>> 10) & 0x3ff) | 0xd800);
|
|
644
|
+
units.push(0xdc00 | (unit & 0x3ff));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
620
647
|
}
|
|
621
|
-
units.push(unit);
|
|
622
648
|
} else {
|
|
623
|
-
units.push(
|
|
649
|
+
units.push(0xFFFD); // replacement character for invalid lead byte
|
|
624
650
|
}
|
|
625
651
|
|
|
626
652
|
if (units.length >= 0x1000) {
|
|
@@ -2602,7 +2628,7 @@ if (!nativeAccelerationDisabled) {
|
|
|
2602
2628
|
if (typeof require == 'function')
|
|
2603
2629
|
extractor = require('cbor-extract');
|
|
2604
2630
|
else
|
|
2605
|
-
extractor = module$1.createRequire((typeof document === 'undefined' ?
|
|
2631
|
+
extractor = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('node.cjs', document.baseURI).href)))('cbor-extract');
|
|
2606
2632
|
if (extractor)
|
|
2607
2633
|
setExtractor(extractor.extractStrings);
|
|
2608
2634
|
} catch (error) {
|