-
-
Notifications
You must be signed in to change notification settings - Fork 357
Closed
Labels
Description
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try online tool?
Description
The predefined entity seems to be parsed twice. &lt; is expected to be parsed to $lt;. However, it is parsed again to <
Input
<SimpleScalarPropertiesInputOutput>
<stringValue>&lt;</stringValue>
</SimpleScalarPropertiesInputOutput>Code
import { XMLParser } from "fast-xml-parser";
const encoded = `<SimpleScalarPropertiesInputOutput>
<stringValue>&lt;</stringValue>
</SimpleScalarPropertiesInputOutput>`;
const parser = new XMLParser({})
const parsed = parser.parse(encoded);
console.log(JSON.stringify(parsed, null, 2));Output
{
"SimpleScalarPropertiesInputOutput": {
"stringValue": "<"
}
}expected data
{
"SimpleScalarPropertiesInputOutput": {
"stringValue": "<"
}
}Would you like to work on this issue?
- Yes
- No
If with sufficient guidance.
It seems to be caused by replacing the escaped value with entity regex in a loop:
fast-xml-parser/src/xmlparser/OrderedObjParser.js
Lines 372 to 375 in 443e8ed
| for(let entityName in this.lastEntities){ | |
| const entity = this.lastEntities[entityName]; | |
| val = val.replace( entity.regex, entity.val); | |
| } |
Reactions are currently unavailable