Description
When using fast-xml-parser in a browser and loading it as an esm module, when trying to parse an xml file that has a DOCTYPE with an entity in it, the DocTypeReader throws the reference error "entityName is not defined".
This can be recreated simply by adding "use strict"; to the top of the src/xmlparser/DocTypeReader.js file and running the projects unit tests. 5 tests will fail with the exact same error. VS Code will also highlight the problem variables.
The simple fix is to simply add let entityName, val; at line 23 of DocTypeReader.js
Input
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note [
<!ENTITY nbsp " ">
<!ENTITY writer "Writer: Donald Duck.">
<!ENTITY copyright "Copyright: W3Schools.">
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body attr="&writer;">Don't forget me this weekend!</body>
<footer>&writer; ©right;</footer>
</note>
Code
const { XMLParser } = require('fast-xml-parser')
const options = {
processEntities: true
}
// The following line will raise an error if run in strict mode
const result = new XMLParser(options)
Output
There should be no error and the entity should be processed correctly.
Would you like to work on this issue?
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
Description
When using fast-xml-parser in a browser and loading it as an esm module, when trying to parse an xml file that has a DOCTYPE with an entity in it, the DocTypeReader throws the reference error "entityName is not defined".
This can be recreated simply by adding
"use strict";to the top of the src/xmlparser/DocTypeReader.js file and running the projects unit tests. 5 tests will fail with the exact same error. VS Code will also highlight the problem variables.The simple fix is to simply add
let entityName, val;at line 23 of DocTypeReader.jsInput
Code
Output
There should be no error and the entity should be processed correctly.
Would you like to work on this issue?
Bookmark this repository for further updates. Visit SoloThought to know about recent features.