You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Numeric character references (A, A) are not decoded unless htmlEntities is enabled #892
With default options, processEntities is true and the five predefined XML entities (<, >, &, ", ') are decoded as expected. Numeric character references, however, are silently left as literal text unless htmlEntities: true is passed:
const{ XMLParser }=require('fast-xml-parser');constparser=newXMLParser();// processEntities defaults to trueparser.parse('<r><>&</r>');// { r: '<>&' } -- named entities decodedparser.parse('<r>AB</r>');// { r: 'AB' } -- numeric refs NOT decoded (expected: { r: 'AB' })parser.parse('<r a="A"/>',{ignoreAttributes: false});// attributes affected the same waynewXMLParser({htmlEntities: true}).parse('<r>AB</r>');// { r: 'AB' } -- only decoded when htmlEntities is on
Numeric character references are not HTML entities - they are part of core XML. Per the XML 1.0 spec (section 4.1, "Character and Entity References"), a well-formed XML processor must recognize &#...; and &#x...; references in content and attribute values, independent of any HTML entity table.
Looking at the source, this seems to come from OrderedObjParser wiring numericAllowed to the htmlEntities option when constructing the EntityDecoder:
this.entityDecoder=newEntityDecoder({namedEntities: { ...namedEntities, ...externalEntities},numericAllowed: this.options.htmlEntities,// <-- ties XML char refs to the HTML entities option
...
});
So a user who parses XML with default options (and htmlEntities defaults to false) gets raw A sequences in their data, while named XML entities are decoded. I ran into this with a feed that encodes non-ASCII characters as numeric refs.
Tested on fast-xml-parser 5.11.2 (npm latest) with Node 22. The same behavior exists in 4.x, so it may be intentional - but if so, it would be great to have it documented next to processEntities, since the current default contradicts XML spec compliance.
We're glad you find this project helpful. We'll try to address this issue ASAP. You can join Discord channel(https://discord.gg/X4Qp9u6Vz) for anonucements and pre release discussions. Don't forget to star this repo.
I am working on the numeric-reference decoding fix and regression coverage for text, attributes, HTML-entity opt-in, and disabled entity processing. AI assistance: OpenClaw (cpa/gpt-6.1-sol); no human review is claimed.
Activity
github-actions commentedon Oct 18, 2026
We're glad you find this project helpful. We'll try to address this issue ASAP. You can join Discord channel(https://discord.gg/X4Qp9u6Vz) for anonucements and pre release discussions. Don't forget to star this repo.
guocn commentedon Oct 22, 2026
I am working on the numeric-reference decoding fix and regression coverage for text, attributes, HTML-entity opt-in, and disabled entity processing. AI assistance: OpenClaw (cpa/gpt-6.1-sol); no human review is claimed.