Numeric character references (A, A) are not decoded unless htmlEntities is enabled
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 64/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- backend
Línea de trabajo
Start by reading OrderedObjParser and its EntityDecoder construction, especially the numericAllowed option mentioned in the issue; then inspect the existing entity-decoding tests. Reproduce the examples for element text and attribute values with default options, and run the relevant parser tests. Done means numeric XML character references decode without enabling htmlEntities, while the existing named-entity behavior remains covered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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');
const parser = new XMLParser(); // processEntities defaults to true
parser.parse('<r><>&</r>');
// { r: '<>&' } -- named entities decoded
parser.parse('<r>AB</r>');
// { r: 'AB' } -- numeric refs NOT decoded (expected: { r: 'AB' })
parser.parse('<r a="A"/>', { ignoreAttributes: false });
// attributes affected the same way
new XMLParser({ 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 = new EntityDecoder({
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 3.1k
- Forks
- 400
- Merge medio
- 3 d 9 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NaturalIntelligence/fast-xml-parser
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
ignoreDeclaration does not ignore lower case doctype declarationQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Enhance type definition for XMLParser `isArray` option when using TypeScriptQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
NaturalIntelligence/fast-xml-parser#803 · 21 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 4 días
-
Feature-Request
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
NaturalIntelligence/fast-xml-parser#779 · 9 comentarios ·
Los mantenedores suelen responder en 4 días
Todos los issues de NaturalIntelligence/fast-xml-parser
Issues similares
-
Place search spins forever when nominatim failsPosiblemente ocupada @jgt87 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
anvaka/city-roads#213 ·
-
mobile UX
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
jellyfin/jellyfin-web#8685 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
SchemaStore/schemastore#6535 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue helia storage tier-1
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QMeshPy/distributed-quantum#53 ·
Los mantenedores suelen responder en 1 día