Skip to content

Bug report: DishJSON converts false and null to empty ArrayBuffer #998

@Danh4

Description

@Danh4

Describe the bug
DishJSON line 20 uses this.value as tertiary conditional check before either stringifying the JSON or initialising a new ArrayBuffer. This means that valid JSON values of null and false are replaced with ArrayBuffer if they are the sole element.

To Reproduce
Steps to reproduce the behaviour or a link to the recipe / input used to cause the bug:

Create a recipe with From Hex and From MessagePack and enter the following inputs:

  1. C0 (null)
  2. C2 (false)
  3. C3 (true)

Expected behaviour

  1. C0 should display null in the output but displays nothing
  2. C2 should display false in the output but displays nothing
  3. C3 should and does correctly display true

Screenshots
N/A

Desktop (if relevant, please complete the following information):
N/A - applies to current head of master

Additional context
The fix should change the tertiary conditional check in DishJSON on line JSON from:

this.value = this.value ? Utils.strToArrayBuffer(JSON.stringify(this.value, null, 4)) : new ArrayBuffer;

to:

this.value = this.value !== undefined ? Utils.strToArrayBuffer(JSON.stringify(this.value, null, 4)) : new ArrayBuffer;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions