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/test.js
CHANGED
|
@@ -910,7 +910,7 @@
|
|
|
910
910
|
return readFixedString(length)
|
|
911
911
|
} else { // not cacheable, go back and do a standard read
|
|
912
912
|
position$1--;
|
|
913
|
-
return read()
|
|
913
|
+
return asSafeString(read())
|
|
914
914
|
}
|
|
915
915
|
let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position$1) : length > 0 ? src[position$1] : 0)) & 0xfff;
|
|
916
916
|
let entry = keyCache[key];
|
|
@@ -962,9 +962,15 @@
|
|
|
962
962
|
return entry.string = readFixedString(length)
|
|
963
963
|
}
|
|
964
964
|
|
|
965
|
+
function asSafeString(property) {
|
|
966
|
+
if (typeof property === 'string') return property;
|
|
967
|
+
if (typeof property === 'number') return property.toString();
|
|
968
|
+
throw new Error('Invalid property type for record', typeof property);
|
|
969
|
+
}
|
|
965
970
|
// the registration of the record definition extension (as "r")
|
|
966
971
|
const recordDefinition = (id, highByte) => {
|
|
967
|
-
let structure = read().map(
|
|
972
|
+
let structure = read().map(asSafeString); // ensure that all keys are strings and
|
|
973
|
+
// that the array is mutable
|
|
968
974
|
let firstByte = id;
|
|
969
975
|
if (highByte !== undefined) {
|
|
970
976
|
id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id);
|
|
@@ -1003,6 +1009,7 @@
|
|
|
1003
1009
|
|
|
1004
1010
|
currentExtensions[0x69] = (data) => {
|
|
1005
1011
|
// id extension (for structured clones)
|
|
1012
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
1006
1013
|
let id = dataView.getUint32(position$1 - 4);
|
|
1007
1014
|
if (!referenceMap)
|
|
1008
1015
|
referenceMap = new Map();
|
|
@@ -1026,6 +1033,7 @@
|
|
|
1026
1033
|
|
|
1027
1034
|
currentExtensions[0x70] = (data) => {
|
|
1028
1035
|
// pointer extension (for structured clones)
|
|
1036
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
1029
1037
|
let id = dataView.getUint32(position$1 - 4);
|
|
1030
1038
|
let refEntry = referenceMap.get(id);
|
|
1031
1039
|
refEntry.used = true;
|