Description
Describe the bug
Very similar to #1849 but for scope
s (or schemaPath
s).
jsonforms/packages/core/src/generators/uischema.ts
Lines 115 to 202 in 075bbc4
As you can see in the above snippet, ref
will be currentRef
of the generated ui-schema:
jsonforms/packages/core/src/generators/uischema.ts
Lines 169 to 176 in 075bbc4
and it will be used as the scope
of control elements:
But it's created by two string-concatenations (line 162 & line 165):
jsonforms/packages/core/src/generators/uischema.ts
Lines 162 to 165 in 075bbc4
const nextRef: string = currentRef + '/properties';
...
const ref = `${nextRef}/${propName}`;
The second one is obviously unsafe. Because we don't know anything about propName
. It may be foo/bar/baz
. Then we have issues in toDataPathSegments()
:
jsonforms/packages/core/src/util/path.ts
Lines 58 to 68 in 075bbc4
Because toDataPathSegments('#/properties/foo/bar/baz')
will be ['foo', 'baz']
!
Expected behavior
/
character should safely be escaped or a string[]
should be used for scope
s:
For example:
// using string[]:
scope = ['#', 'properties', 'foo/bar/baz']
// AJV-like `instancePath` encoding:
scope = '#/properties/foo~1bar~1baz'
Then toDataPathSegments()
can parse its input correctly and will return ['foo/bar/baz']
.
Steps to reproduce the issue
- Go to Playground
- Set:
JSON-Schema
:{ "type": "object", "properties": { "foo/bar": { "type": "string" } } }
UI-Schema
:false
Data
:{}
Screenshots
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