Skip to content

Commit

Permalink
When appropriate, reinterpret pair as double
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jul 26, 2024
1 parent 58930a6 commit 4938ff2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ee/katc/deserialize_firefox.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
tagBooleanObject uint32 = 0xffff000a
tagStringObject uint32 = 0xffff000b
tagEndOfKeys uint32 = 0xffff0013
tagFloatMax uint32 = 0xfff00000
)

// deserializeFirefox deserializes a JS object that has been stored by Firefox
Expand Down Expand Up @@ -151,7 +152,13 @@ func deserializeObject(srcReader io.ByteReader) (map[string][]byte, error) {
case tagNull, tagUndefined:
resultObj[nextKeyStr] = nil
default:
return nil, fmt.Errorf("cannot process object key `%s`: unknown tag type `%x` with data `%d`", nextKeyStr, valTag, valData)
if valTag < tagFloatMax {
// We want to reinterpret (valTag, valData) as a single double value instead
d := uint64(valData) | uint64(valTag)<<32
resultObj[nextKeyStr] = []byte(strconv.FormatUint(d, 10))
} else {
return nil, fmt.Errorf("cannot process object key `%s`: unknown tag type `%x` with data `%d`", nextKeyStr, valTag, valData)
}
}
}

Expand Down

0 comments on commit 4938ff2

Please sign in to comment.