Reader should be capable of transparent EOL normalization

Abierto
#1,003 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
backend

Línea de trabajo

Start by tracing the Reader constructors and the XML content methods mentioned in the issue, then read XML 1.0 Section 2.11 and the linked follow-up issue. The proposed change spans buffering, decoding, normalization, zero-copy behavior, and compatibility for noncompliant input; define the desired API and tradeoffs before implementation. Done means reader behavior follows the selected XML specification consistently, with an explicit approach for disabling normalization where needed.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement

Followup to https://github.com/tafia/quick-xml/issues/158

Per XML specification, all XML readers should perform line-ending normalization as a pre-processing step (or functionally behaving as if it were a pre-processing step - XML 1.0 Section 2.11)

This is both an ergonomic issue and also a minor correctness issue, because EOL normalization is blind to document contents and therefore also applies within elements, e.g. <?xml\r?> ought to be parsed as <?xml\n?> - which libxml2 does in fact do.

It's an ergonomic issue in the sense that a user should not need to care about it - the .xml_content(), .xml10_content(), .xml11_content() functions etc. ought to be superfluous and are potentially error prone. The user also shouldn't need to track the version declared in the declaration - they likely just want the document to be processed according to the correct specification per the declaration or according to the one they specify, but that need not change on a per-element basis.

Performing universal EOL normalization as a pre-processor pass through a bufffer would reduce total allocations and likely improve performance on average, while improving ergonomics and compliance.

The mechanism could also likely be used as a base upon which line/column tracking (https://github.com/tafia/quick-xml/issues/109) could be added.

Potentially troublesome aspects:

  • For users who process noncompliant "almost-XML" documents that contain binary blobs, we would need a way to disable it, possibly document-wide, or perhaps just during the usage of stream().
  • We might want to make the current Reader constructors from_reader(), from_str(), from_bytes() methods buffered by-default, and perhaps add a new constructor which takes only a pre-processed XmlDoc type or similar where decoding + normalization has already happened, allowing proper zero-copy. If we keep zero-copy (which isn't really zero-copy in practice) at all - maybe worth doing some benchmarking to see how much time is actually saved vs. just having a buffered path. XML parsing is easily 25-50x slower than copying the bytes around once or twice anyway, and the XmlSource code + macros are all quite complex.
Lenguaje dominante
Rust
Estrellas
1.6k
Forks
299
Merge medio
2 d 4 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tafia/quick-xml

Todos los issues de tafia/quick-xml

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.