msgpackr 1.10.0 → 1.10.1
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/dist/index-no-eval.cjs +10 -2
- 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 +10 -2
- 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 +10 -2
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +10 -2
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +10 -2
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/package.json +1 -1
- package/unpack.js +10 -2
package/dist/node.cjs
CHANGED
|
@@ -914,7 +914,7 @@ function readKey() {
|
|
|
914
914
|
return readFixedString(length)
|
|
915
915
|
} else { // not cacheable, go back and do a standard read
|
|
916
916
|
position$1--;
|
|
917
|
-
return read()
|
|
917
|
+
return asSafeString(read())
|
|
918
918
|
}
|
|
919
919
|
let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position$1) : length > 0 ? src[position$1] : 0)) & 0xfff;
|
|
920
920
|
let entry = keyCache[key];
|
|
@@ -966,9 +966,15 @@ function readKey() {
|
|
|
966
966
|
return entry.string = readFixedString(length)
|
|
967
967
|
}
|
|
968
968
|
|
|
969
|
+
function asSafeString(property) {
|
|
970
|
+
if (typeof property === 'string') return property;
|
|
971
|
+
if (typeof property === 'number') return property.toString();
|
|
972
|
+
throw new Error('Invalid property type for record', typeof property);
|
|
973
|
+
}
|
|
969
974
|
// the registration of the record definition extension (as "r")
|
|
970
975
|
const recordDefinition = (id, highByte) => {
|
|
971
|
-
let structure = read().map(
|
|
976
|
+
let structure = read().map(asSafeString); // ensure that all keys are strings and
|
|
977
|
+
// that the array is mutable
|
|
972
978
|
let firstByte = id;
|
|
973
979
|
if (highByte !== undefined) {
|
|
974
980
|
id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id);
|
|
@@ -1007,6 +1013,7 @@ currentExtensions[0x65] = () => {
|
|
|
1007
1013
|
|
|
1008
1014
|
currentExtensions[0x69] = (data) => {
|
|
1009
1015
|
// id extension (for structured clones)
|
|
1016
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
1010
1017
|
let id = dataView.getUint32(position$1 - 4);
|
|
1011
1018
|
if (!referenceMap)
|
|
1012
1019
|
referenceMap = new Map();
|
|
@@ -1030,6 +1037,7 @@ currentExtensions[0x69] = (data) => {
|
|
|
1030
1037
|
|
|
1031
1038
|
currentExtensions[0x70] = (data) => {
|
|
1032
1039
|
// pointer extension (for structured clones)
|
|
1040
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
1033
1041
|
let id = dataView.getUint32(position$1 - 4);
|
|
1034
1042
|
let refEntry = referenceMap.get(id);
|
|
1035
1043
|
refEntry.used = true;
|