flowable / flowable/flowable-engine

Text with xml entity references in <extensionElements> is truncated

Open
#3,267 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
7h 8m
Merged PRs (30d)
2

Description

# 1. Description
Bpmn xml text like this:
```xml





a>b


```
After convertion to json, the text `a>b` in element is converted to `b`, while expection is: `a>b`.

# 2. Reason
## 2.1 Behavior of XMLStreamReader
The XMLStreamReader treate entity references specially. `a>b` will report 3 times.
I wrote a simple code:
```java
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import java.io.StringReader;

public class Application {
public static void main(String[] args){
String xmlString = " a>b";
XMLInputFactory xif = XMLInputFactory.newInstance();
xif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
try {
XMLStreamReader xtr = xif.createXMLStreamReader(new StringReader(xmlString));
while (xtr.hasNext()) {
xtr.next();
if (xtr.isCharacters()) {
System.out.printf("eventType:%d, text:%s\n", xtr.getEventType(), xtr.getText());
}
}
}catch (Exception ex){
System.out.println(ex);
}
}
}
```
The output is:
```
eventType:4, text:a
eventType:4, text:>
eventType:4, text:b
```
We can see that,there is only a line `a>b`, but XMLStreamReader reported 3 times.

## 2.2 BpmnXMLUtil.parseChildElements() only got the last reported text
Relatived code :
https://github.com/flowable/flowable-engine/blob/d763b143d9b80b32ec8483fe6584429283e87e75/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/util/BpmnXMLUtil.java#L190-L204

At line 195, `extensionElement.setElementText(xtr.getText().trim())` only got the last reported text `b`.

# 3. Suggestion
Modify L195 as: extensionElement.setElementText(extensionElement.getElementText() + xtr.getText().trim())

Please forgive me for my poor English.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.