Skip to content

feat: 插件BPMNAdapter支持特殊字符串转义#2381

Merged
DymoneLewis merged 1 commit into
masterfrom
feature/BPMNAdapter-special-transform-2.2
Mar 3, 2026
Merged

feat: 插件BPMNAdapter支持特殊字符串转义#2381
DymoneLewis merged 1 commit into
masterfrom
feature/BPMNAdapter-special-transform-2.2

Conversation

@DymoneLewis
Copy link
Copy Markdown
Collaborator

fix #2375

@DymoneLewis DymoneLewis requested a review from Copilot March 3, 2026 06:35
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: dd4c555

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #2375 by adding proper XML escaping in the BPMNElementsAdapter serialization/deserialization utilities so BPMN shape names (and other text/attribute content) containing special characters can round-trip correctly.

Changes:

  • Introduced a shared escapeXml helper in json2xml.ts and applied it to attribute values and text node content.
  • Replaced xml2json’s xml_escape implementation with the shared escapeXml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/extension/src/bpmn-elements-adapter/xml2json.ts Reuses escapeXml for XML generation escaping logic in ObjTree.
packages/extension/src/bpmn-elements-adapter/json2xml.ts Adds escapeXml, escapes attributes/text output, and adjusts falsy handling in XML serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 57 to +62
if (name === '-json') return ''
if (obj !== 0 && obj !== false && !obj) {
return `${prefix}<${name} />`
}
if (name === '#text') {
return prefix + obj
return prefix + escapeXml(String(obj))
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toXml now returns a self-closing element for falsy values before handling special node names like #text/#cdata-section/#comment. If a node uses #text with an empty string (valid when an element has attributes but empty text), this will emit <#text />, which is not valid XML and changes semantics. Consider moving the falsy short-circuit below the #text/#cdata/#comment branches (or exclude names starting with # from the self-closing behavior).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread packages/extension/src/bpmn-elements-adapter/json2xml.ts
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

@DymoneLewis I've opened a new pull request, #2383, to work on those changes. Once the pull request is ready, I'll request review from you.

@DymoneLewis DymoneLewis merged commit 0f5fd6a into master Mar 3, 2026
4 checks passed
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无法回显问题

4 participants