Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
从 packages/core/src/util/path.ts 开始;issue 指出其中 toDataPath 的正则表达式是路径错误的原因。检查现有的路径转换测试,并补充对名为 then、else 或 something_else 的属性,以及完整关键字片段的测试。完成标准是保留属性片段,同时仍然移除 schema 关键字片段,使报告的路径变为 something_else.name。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
toDataPathSegments strips then/ and else/ (and anyOf/N/ etc.) anywhere in the scope string, not only as whole path segments. So a scope that goes through a property named then, else, something_else, strengthen, ... is turned into a wrong data path:
import { toDataPath } from "@jsonforms/core";
toDataPath("#/properties/something_else/properties/name"); // "something_properties"
toDataPath("#/properties/then/properties/name"); // "properties"
toDataPath("#/properties/strengthen/properties/x"); // "strengproperties"
In a form the control shows nothing and typing writes to a new top-level key. With the React vanilla renderers, data { something_else: { name: "Bob" } } shows an empty input, and typing "Alice" produces
{"something_else":{"name":"Bob"},"something_properties":"Alice"}
Rules whose condition scope goes through such a property read the wrong value too.
Expected behavior
toDataPath("#/properties/something_else/properties/name") is "something_else.name", the input shows "Bob", and typing gives {"something_else":{"name":"Alice"}}. Only whole then/else segments (as in #/then/properties/x) should be dropped.
Steps to reproduce the issue
import { JsonForms } from "@jsonforms/react";
import { vanillaRenderers, vanillaCells } from "@jsonforms/vanilla-renderers";
const schema = {
type: "object",
properties: {
something_else: { type: "object", properties: { name: { type: "string" } } },
},
};
const uischema = {
type: "VerticalLayout",
elements: [{ type: "Control", scope: "#/properties/something_else/properties/name" }],
};
<JsonForms
schema={schema}
uischema={uischema}
data={{ something_else: { name: "Bob" } }}
renderers={vanillaRenderers}
cells={vanillaCells}
onChange={({ data }) => console.log(JSON.stringify(data))}
/>;
- Render the form: the input is empty instead of "Bob".
- Type "Alice":
onChangelogs{"something_else":{"name":"Bob"},"something_properties":"Alice"}.
With a property named name2 instead, the same form works.
Screenshots
No response
Which Version of JSON Forms are you using?
v3.8.0 (also master 942b76f)
Package
Core
Additional context
The regexes in packages/core/src/util/path.ts are /(anyOf|allOf|oneOf)\/[\d]+\//g and /(then|else)\//g. They match inside a segment, and they also match a segment that is a property name, so the scope would need to be split into segments first and then/else/anyOf/N dropped only where a keyword is expected (not right after properties).
Credit: https://ucsbplse.github.io/
- 主要语言
- TypeScript
- 星标
- 2.8k
- 派生
- 423
- 平均合并
- 5 天 16 小时
- 30 天内合并 PR
- 9
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
eclipsesource/jsonforms 的其他 Issue
-
Add "append" and "prepend" slots for vue-vuetify extended renderers可能已有人在做 @simeyc 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
eclipsesource/jsonforms#2668 ·
维护者通常 1 天内回复
-
angular material
难度 1/5 1 小时以内 新手友好度 88/100
eclipsesource/jsonforms#2662 · 1 条评论 ·
维护者通常 1 天内回复
-
core
难度 2/5 1-3 小时 新手友好度 75/100
eclipsesource/jsonforms#2570 · 1 条评论 ·
维护者通常 1 天内回复
-
dev
难度 2/5 1-3 小时 新手友好度 50/100
eclipsesource/jsonforms#2651 ·
维护者通常 1 天内回复
-
angular material
难度 4/5 3-5 天 新手友好度 68/100
eclipsesource/jsonforms#2630 ·
维护者通常 1 天内回复
查看 eclipsesource/jsonforms 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
README の通知条件を実際の判定処理に合わせる可能已有人在做 @unhappychoice 今天认领。 未关闭factory:in-progress priority:medium
难度 1/5 1 小时以内 新手友好度 90/100
unhappychoice/oss-issue-opener#395 · 1 条评论 ·
维护者通常 1 天内回复
-
bug Website
难度 2/5 1-3 小时 新手友好度 77/100
OWASP/OWASP-Hunting#88 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复