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/index-no-eval.cjs
CHANGED
|
@@ -859,7 +859,7 @@
|
|
|
859
859
|
return readFixedString(length)
|
|
860
860
|
} else { // not cacheable, go back and do a standard read
|
|
861
861
|
position$1--;
|
|
862
|
-
return read()
|
|
862
|
+
return asSafeString(read())
|
|
863
863
|
}
|
|
864
864
|
let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position$1) : length > 0 ? src[position$1] : 0)) & 0xfff;
|
|
865
865
|
let entry = keyCache[key];
|
|
@@ -911,9 +911,15 @@
|
|
|
911
911
|
return entry.string = readFixedString(length)
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
+
function asSafeString(property) {
|
|
915
|
+
if (typeof property === 'string') return property;
|
|
916
|
+
if (typeof property === 'number') return property.toString();
|
|
917
|
+
throw new Error('Invalid property type for record', typeof property);
|
|
918
|
+
}
|
|
914
919
|
// the registration of the record definition extension (as "r")
|
|
915
920
|
const recordDefinition = (id, highByte) => {
|
|
916
|
-
let structure = read().map(
|
|
921
|
+
let structure = read().map(asSafeString); // ensure that all keys are strings and
|
|
922
|
+
// that the array is mutable
|
|
917
923
|
let firstByte = id;
|
|
918
924
|
if (highByte !== undefined) {
|
|
919
925
|
id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id);
|
|
@@ -952,6 +958,7 @@
|
|
|
952
958
|
|
|
953
959
|
currentExtensions[0x69] = (data) => {
|
|
954
960
|
// id extension (for structured clones)
|
|
961
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
955
962
|
let id = dataView.getUint32(position$1 - 4);
|
|
956
963
|
if (!referenceMap)
|
|
957
964
|
referenceMap = new Map();
|
|
@@ -975,6 +982,7 @@
|
|
|
975
982
|
|
|
976
983
|
currentExtensions[0x70] = (data) => {
|
|
977
984
|
// pointer extension (for structured clones)
|
|
985
|
+
if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled')
|
|
978
986
|
let id = dataView.getUint32(position$1 - 4);
|
|
979
987
|
let refEntry = referenceMap.get(id);
|
|
980
988
|
refEntry.used = true;
|