Skip to content

Commit

Permalink
[KATC] Add support for doubles to indexeddb parsing (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany authored Nov 19, 2024
1 parent bcf0102 commit caa9ede
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ee/indexeddb/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
// numbers
tokenInt32 byte = 0x49 // I
tokenUint32 byte = 0x55 // U
tokenDouble byte = 0x4e // N
// strings
tokenAsciiStr byte = 0x22 // "
tokenUtf16Str byte = 0x63 // c
Expand Down Expand Up @@ -207,6 +208,12 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader *byt
return obj, fmt.Errorf("decoding int32 for `%s`: %w", currentPropertyName, err)
}
obj[currentPropertyName] = []byte(strconv.Itoa(int(propertyInt)))
case tokenDouble:
var d float64
if err := binary.Read(srcReader, binary.NativeEndian, &d); err != nil {
return obj, fmt.Errorf("decoding double for `%s`: %w", currentPropertyName, err)
}
obj[currentPropertyName] = []byte(strconv.FormatFloat(d, 'f', -1, 64))
case tokenBeginSparseArray:
arr, err := deserializeSparseArray(ctx, slogger, srcReader)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ee/katc/test_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Loading the page will populate IndexedDB with the desired data. You should also
console log message to this effect.

The file will now be available with other IndexedDB files. On macOS, Chrome indexeddb files
can be found at `/Users/<my-username>/Library/Application Support/Google/Chrome/Default/IndexedDB/file__0.indexeddb.leveldb`.
can be found at `/Users/<my-username>/Library/Application Support/Google/Chrome/<Profile Name>/IndexedDB/file__0.indexeddb.leveldb`.
(The name of the indexeddb file will likely be the same, but you can confirm the origin
matches in Dev Tools in your browser by going to Application => IndexedDB => launchertestdb.)
On macOS, Firefox sqlite files can be found at a path similar to this one:
Expand Down
Binary file modified ee/katc/test_data/indexeddbs/file__0.indexeddb.leveldb.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions ee/katc/test_data/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
}
],
noDetails: [], // Empty array
email: "[email protected]"
email: "[email protected]",
someTimestamp: 1720034607 // *unint32
},
{
uuid: "03b3e669-3e7a-482c-83b2-8a800b9f804f",
Expand Down Expand Up @@ -86,7 +87,8 @@
}
],
noDetails: [], // Empty array
email: "[email protected]"
email: "[email protected]",
someTimestamp: 1726096312 // *unint32
},
];
objectStore.transaction.oncomplete = (event) => {
Expand Down

0 comments on commit caa9ede

Please sign in to comment.