Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"dependencies": {
"@typed-mxgraph/typed-mxgraph": "~1.0.8",
"es-toolkit": "~1.45.0",
"fast-xml-parser": "5.4.2",
"fast-xml-parser": "5.5.7",
"mxgraph": "4.2.2"
},
"devDependencies": {
Expand Down
21 changes: 16 additions & 5 deletions src/component/parser/xml/BpmnXmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,27 @@
*/
processEntities: false,

// See https://github.com/NaturalIntelligence/fast-xml-parser/blob/v4.3.4/docs/v4/2.XMLparseOptions.md#attributevalueprocessor
attributeValueProcessor: (name: string, value: string, nodePath: string): unknown => {
if (isNumeric(name, nodePath)) {
// Use Matcher object (jPath: false) to get paths without namespace prefixes via toString('.', false).
// With jPath: true (default), toString() includes namespace prefixes (e.g. "bpmn:definitions.bpmndi:BPMNDiagram")
// which don't match our expected paths in nodesWithNumericAttributes.
jPath: false,

// See https://github.com/NaturalIntelligence/fast-xml-parser/blob/v5.5.7/docs/v4%2C%20v5/2.XMLparseOptions.md#attributevalueprocessor
attributeValueProcessor: (attributeName: string, attributeValue: string, nodePathOrMatcher: unknown): unknown => {
// nodePathOrMatcher is a Matcher instance (jPath: false). Get path without namespace prefixes.
const nodePath =
typeof nodePathOrMatcher === 'object' && nodePathOrMatcher !== null
? String((nodePathOrMatcher as { toString(separator?: string, includeNs?: boolean): string }).toString('.', false))
: String(nodePathOrMatcher);

Check warning on line 82 in src/component/parser/xml/BpmnXmlParser.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'nodePathOrMatcher' will use Object's default stringification format ('[object Object]') when stringified.

See more on https://sonarcloud.io/project/issues?id=process-analytics_bpmn-visualization-js&issues=AZ0MPL8G69j3AYRLlI2j&open=AZ0MPL8G69j3AYRLlI2j&pullRequest=3494
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: SonarQube complains about this line

'nodePathOrMatcher' will use Object's default stringification format ('[object Object]') when stringified.

See https://sonarcloud.io/project/issues?sinceLeakPeriod=true&issueStatuses=OPEN%2CCONFIRMED&pullRequest=3494&id=process-analytics_bpmn-visualization-js&open=AZ0MPL8G69j3AYRLlI2j


if (isNumeric(attributeName, nodePath)) {
// The strnum lib used by fast-xml-parser is not able to parse all numbers
// The only available options are https://github.com/NaturalIntelligence/fast-xml-parser/blob/v4.3.4/docs/v4/2.XMLparseOptions.md#numberparseoptions
Comment thread
tbouffard marked this conversation as resolved.
Outdated
// This is a fix for https://github.com/process-analytics/bpmn-visualization-js/issues/2857
return Number(value);
return Number(attributeValue);
}

return this.processAttribute(value);
return this.processAttribute(attributeValue);
},
};
private readonly xmlParser: XMLParser = new XMLParser(this.x2jOptions);
Expand Down
Loading