Attribute values are not normalized as XML 1.0 section 3.3.3 requires
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- backend
Direzione di ricerca
Start by reading the XMLParser attribute handling and entity decoding paths, then check issue #330 for the existing behavior around preserving newlines. The report says normalization must happen before entity and character references are decoded and may need to be opt-in. Done means literal attribute whitespace normalizes to spaces while a decoded character reference preserves its newline; add coverage for both forms.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- 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?
- Have you checked the docs for helpful APIs and examples?
Description
XMLParser does not apply the attribute-value normalization of XML 1.0, section 3.3.3. A literal line feed or tab in an attribute value is kept as is, but the spec says that a conforming processor replaces each literal whitespace character (#x20, #xD, #xA, #x9) with a space, and only a character reference such as adds the character itself.
Because the parser keeps the literal characters, the two forms cannot be told apart once character references are decoded (htmlEntities: true or an entityDecoder): a="x y" and an attribute with a real line break both become "x\ny". An application that writes the value back has no way to know whether the source meant a space or a line feed.
I found no option for this. #330 asked for the opposite (keeping newlines) in 2021, and that is the current behavior, so a change would probably have to be opt-in, for example an option such as normalizeAttributeValues: true. The normalization would have to happen before entity and character references are decoded.
Input
<r a="x
y"/>
Code
import { XMLParser } from "fast-xml-parser"; // 5.12.0
const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "" });
parser.parse('<r a="x\ny"/>').r.a; // "x\ny"
parser.parse('<r a="x\ty"/>').r.a; // "x\ty"
parser.parse('<r a="x\r\ny"/>').r.a; // "x\ny"
parser.parse('<r a="x y"/>').r.a; // "x y" (numeric references are not decoded by default, see #892)
Output
"x\ny"
"x\ty"
"x\ny"
expected data
"x y"
"x y"
"x y"
"x\ny" // for a="x y", once numeric references are decoded
For comparison, @xmldom/xmldom returns "x y" for the first two inputs and "x\ny" for a="x y".
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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NaturalIntelligence/fast-xml-parser
-
A processing instruction with no target passes validation, then the builder prints invalid XMLForse già presa @bardrop l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NaturalIntelligence/fast-xml-parser#927 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
XMLValidator accepts double hyphens inside commentsForse già presa @Sskift l’ha presa 16 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
NaturalIntelligence/fast-xml-parser#903 · 3 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
XMLValidator accepts raw < and & in attribute valuesForse già presa @jeromeyyy l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NaturalIntelligence/fast-xml-parser#900 · 3 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
getMetaDataSymbol() declares a boxed SymbolForse già presa @chiragbitoni l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di NaturalIntelligence/fast-xml-parser
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
Extended search drops any query term that contains a line breakForse già presa @goranai l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
0.3.14: pdfmake.virtualfs renamed to sharedVirtualfs without changelog entry (breaking change)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno