Inconsistent handling of tags starting with digits (Parser accepts invalid XML)

Open
#1,035 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
53/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start by reading the parser’s name handling and its existing XML well-formedness tests; the issue does not identify specific files or tests. Check how element names beginning with digits are accepted, then add coverage for the shown <1stElement> case and confirm parsing rejects it with an error. The expected behavior is strict validation of XML name rules.

Written by the indexing model from the issue text.

Description

enhancement

There is a critical inconsistency in how quick-xml handles tags that begin with digits. Because XML element naming rules (NCName constraints), these elements are problematic.

Currently:
The Parser is too permissive: It accepts XML that violates XML well-formedness rules (tags starting with digits).

This leads to a complete breakdown of interoperability and data integrity when round-tripping data through quick-xml.


Permissive Parsing

The parser accepts invalid XML where element tags values imply names starting with a digit. Standard-compliant parsers should handle these carefully, but quick-xml current behavior accepts them as valid XML data despite the underlying XML structure being potentially malformed or ambiguous.

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <!-- This tag name starts with '1', which is illegal. 
         Any conformant XML parser will reject this document. -->
    <1stElement>Data</1stElement>
</root>

Expected Behavior

Parser should strictly validate XML well-formedness. If a tag name violates XML naming rules, it should ideally raise an error or handle the namespace logic strictly according to the XML spec.

Dominant language
Rust
Stars
1.6k
Forks
299
Avg merge
2d 4h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tafia/quick-xml

All issues in tafia/quick-xml

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.