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() {
914914 return readFixedString ( length )
915915 } else { // not cacheable, go back and do a standard read
916916 position --
917- return read ( ) . toString ( )
917+ return asSafeString ( read ( ) )
918918 }
919919 let key = ( ( length << 5 ) ^ ( length > 1 ? dataView . getUint16 ( position ) : length > 0 ? src [ position ] : 0 ) ) & 0xfff
920920 let entry = keyCache [ key ]
@@ -966,9 +966,15 @@ function readKey() {
966966 return entry . string = readFixedString ( length )
967967}
968968
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+ }
969974// the registration of the record definition extension (as "r")
970975const 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
972978 let firstByte = id
973979 if ( highByte !== undefined ) {
974980 id = id < 32 ? - ( ( highByte << 5 ) + id ) : ( ( highByte << 5 ) + id )
You can’t perform that action at this time.
0 commit comments