Skip to content

Is "dot-separated" path safe? #1849

Closed
Closed
@mirismaili

Description

@mirismaili

Describe the bug

As you know there is a path prop that is passed to the renderer that indicates the location of data (that should be rendered by that renderer) in the root data object (e.g. 'foo.bar').

It's a dot-separated string:

export const composeWithUi = (scopableUi: Scopable, path: string): string => {
const segments = toDataPathSegments(scopableUi.scope);
if (isEmpty(segments) && path === undefined) {
return '';
}
return isEmpty(segments) ? path : compose(path, segments.join('.'));
};

compose(path, segments.join('.'))

Is this safe? Then 'foo.bar' points to data.foo.bar or data['foo.bar']?

Expected behavior

The library should can distinguish between these paths. For example, using arrays (instead of strings):

path1 = ['foo', 'bar']
path2 = ['foo.bar']

Steps to reproduce the issue

  1. Go to Playground

  2. Set:
    JSON-Schema:

    {
      "type": "object",
      "properties": {
        "my.name": {
          "type": "string"
        }
      }
    }

    UI-Schema:

    false

    Data:

    {
      "my.name": "S. Mahdi",
      "my": {
        "name": "MirIsmaili"
      }
    }

As you can see in the playground, the synchronization process flows along with the green arrows (see below screenshot), but NOT along with the red arrows. (When you edit the form, data['my.name'] will be updated (only) and when you edit data.my.name in the editor (only), the form will be updated).

Screenshots

image

In which browser are you experiencing the issue?

Google Chrome v96.0.4664.93 (Official Build) (64-bit)

Framework

No response

RendererSet

No response

Additional context

No response

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