Skip to content

dictionary extension errors with certain values #844

Description

@RedMan13

if you put null into the parse block in the dictionaries extension it errors with Uncaught TypeError: Cannot convert undefined or null to object
on top of that values such as "text" and 20 produce unexpected results
possible patch:

    dict_parse({ OBJ, DICT }) {
      let dict = null;
      try {
        dict = JSON.parse(OBJ);
+       if (typeof dict !== 'object') dict = {error: 'data must be an object or array'};
      } catch (e) {
        dict = {"error": String(e)};
      }
+     // add the length value if and only if this is an array
+     if (Array.isArray(dict)) {
+       const entries = Object.entries(dict)
+       entries.push(['length', dict.length])
+       dict = Object.fromEntries(entries)
+     }
      dictionaries.set(DICT, new Map(Object.entries(dict)));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions