Builder emits forbidden XML control characters and validator accepts them

Aperta
#902 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, xml
Ambito
api, backend

Direzione di ricerca

Start with the XML builder and validator entry points in the fast-xml-parser source, where text values are escaped before output; the repro in the issue calls XMLBuilder().build and XMLValidator.validate on { a: "\u0000" }. Check whether the builder's text handling and the validator's character checks cover the XML 1.0 forbidden range U+0000-U+0008, U+000B, U+000C, U+000E-U+001F. Done when the builder no longer emits these code points and XMLValidator.validate rejects text containing them, with tests for U+0000 and U+0001.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • Are you running the latest version? (5.11.2, master at cf66a9658004553bc740616e6c7a4912e7e9aab6)
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration? (default builder, validator, and parser options)
  • Did you try the online tool? (it reports Valid XML for the standalone NUL sample)
  • Have you checked the docs for helpful APIs and examples?
Description

The builder emits U+0000 and U+0001 verbatim, and the validator accepts the resulting text as valid XML. XML 1.0 Character Range excludes both code points. This can produce documents that a conforming XML reader cannot consume.

Input

{ a: "\u0000" } (the JavaScript string contains an actual NUL after escape processing). U+0001 behaves the same. U+0009 and U+000A are valid controls.

Code
const { XMLBuilder, XMLValidator, XMLParser } = require("./lib/fxp.cjs");
const xml = new XMLBuilder().build({ a: "\u0000" });
console.log(JSON.stringify(xml));
console.log(XMLValidator.validate(xml));
console.log(JSON.stringify(new XMLParser().parse(xml, true)));
Output
"<a>\u0000</a>"
true
{"a":"\u0000"}
Expected data

The builder should avoid emitting forbidden XML characters, and the validator should reject XML text containing U+0000 or U+0001.

Would you like to work on this issue?

  • Yes
  • No
Lingua principale
JavaScript
Stelle
3.1k
Fork
410
Merge medio
4g 15h
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NaturalIntelligence/fast-xml-parser

Tutte le issue di NaturalIntelligence/fast-xml-parser

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.