File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -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 --
917
- return read ( ) . toString ( )
917
+ return asSafeString ( read ( ) )
918
918
}
919
919
let key = ( ( length << 5 ) ^ ( length > 1 ? dataView . getUint16 ( position ) : length > 0 ? src [ position ] : 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 ( property => property . toString ( ) ) // ensure that all keys are strings and that the array is mutable
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 )
You can’t perform that action at this time.
0 commit comments