Skip to content

BPMNAdapter: sanitize XML name attributes during import to preserve special-character labels#2379

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-bpmn-adapter-issue
Draft

BPMNAdapter: sanitize XML name attributes during import to preserve special-character labels#2379
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-bpmn-adapter-issue

Conversation

Copy link

Copilot AI commented Mar 2, 2026

BPMN shape labels containing raw special characters (<, >, &) could break XML parsing in BPMNAdapter, causing names to fail to round-trip on import. This aligns bpmn-elements-adapter behavior with the previously fixed adapter path by sanitizing name attributes before parsing.

  • Change: import-side sanitization in bpmn-elements-adapter

    • Added sanitizeNameAttributes(xml: string) in packages/extension/src/bpmn-elements-adapter/index.ts.
    • Applied sanitization in adapterXmlIn when input is an XML string, before lfXml2Json(...).
    • Only name="..." attribute values are normalized; existing entities remain intact.
  • Change: focused regression coverage

    • Updated packages/extension/src/bpmn-elements-adapter/__tests__/adapter_in.test.js with cases for:
      • raw special chars in names (e.g. A < B & C)
      • mixed escaped/unescaped content (e.g. A &amp; B < C)
    • Assertions verify node text restores correctly after BPMN import.
private sanitizeNameAttributes(xml: string): string {
  return xml.replace(/name="([^"]*)"/g, (_, val) => {
    const safe = val
      .replace(/&(?!#?\w+;)/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
    return `name="${safe}"`
  })
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug Report]: BPMNAdapter中各shape的名称中有特殊字符bpmn无法回显问题</issue_title>
<issue_description>### 发生了什么?

[Bug Report]: bpmn流程中各shape的名称中有特殊字符bpmn无法回显bug #2269
#2269

之前报过上面的bug,等上面的bug修复后,本地拉去测试多个版本发现bug仍在存在。经过与VX管理员沟通得到如下信息,按照要求报个BPMNAdapter修复的bug。

BPMNAdapter还没加上这个逻辑,目前只给bpmnAdpter加了,可以提个issue记录一下,节后发个版给BPMNAdapter也支持上

之前用过bpmn.js,相比之下logicflow非常好用,非常感谢!

logicflow/core版本

2.1.5+

logicflow/extension版本

2.1.5+

logicflow/engine版本

No response

浏览器&环境

Chrome</issue_description>

<agent_instructions>现在存在的问题是bpmn里面的转化调用的是bpmnAdapter 按照之前的一次改动已经把节点里面的内容特殊字符转义了,现在要想在bpmnAdapter也进行转义应该在哪里写,现在所有的BPMN里面的内容都在extension包中</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

⚠️ No Changeset found

Latest commit: 457c6be

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI and others added 2 commits March 2, 2026 06:38
…butes

Co-authored-by: CraneReturn <127602190+CraneReturn@users.noreply.github.com>
…port

Co-authored-by: CraneReturn <127602190+CraneReturn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix BPMNAdapter special character reflection issue BPMNAdapter: sanitize XML name attributes during import to preserve special-character labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report]: BPMNAdapter中各shape的名称中有特殊字符bpmn无法回显问题

2 participants