Skip to content

Unable to deserialize nested objects #8

@JSCU-CNI

Description

@JSCU-CNI

Thank you for creating this library, it is very useful and concise. I think I stumbled upon a small bug when deserializing object references inside an object. See the example below.

When serializing the following object:

v8.serialize({
  "string_primitive": "hello primitive",
  "string_object": new String("hello object"),
  "bool_primitive_true": true,
}).toString("base64")

And then decoding it:

v8serialize.loads(base64.b64decode(...))

Will result in the following serializer error:

v8serialize._errors.DecodeV8SerializeError: JSObject has a key encoded with
tag kTrue that is not a number or string tag. Valid JavaScript Object Keys: 
kDouble, kInt32, kNumberObject, kOneByteString, kStringObject, kTwoByteString,
kUint32, kUtf8String: position=90, 
data=b'\xff\x0fo"\x10string_primitive"\x0fhello primitive"\rstring_objects"\x0chello object"\x13bool_primitive_trueT{\x03'
00000000  ff 0f 6f 22 10 73 74 72  69 6e 67 5f 70 72 69 6d   ..o".string_prim
00000010  69 74 69 76 65 22 0f 68  65 6c 6c 6f 20 70 72 69   itive".hello pri
00000020  6d 69 74 69 76 65 22 0d  73 74 72 69 6e 67 5f 6f   mitive".string_o
00000030  62 6a 65 63 74 73 22 0c  68 65 6c 6c 6f 20 6f 62   bjects".hello ob
00000040  6a 65 63 74 22 13 62 6f  6f 6c 5f 70 72 69 6d 69   ject".bool_primi
00000050  74 69 76 65 5f 74 72 75  65 54 7b 03               tive_trueT{.

It seems that "string_object": new String("hello object") (parsing in read_js_primitive_object) causes read_js_object and _read_js_object_properties to read further than it should as the String object has already finished.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions