Skip to content

XML tokenizer falsely reports xml:lang + lang as duplicate attributes #775

Description

@leecbaker

xml5ever rejects valid namespace-qualified XML attributes when a qualified attribute precedes an unqualified attribute with the same local name. This appears to be order dependent.

Example 1

use markup5ever_rcdom::RcDom;
use xml5ever::driver::parse_document;
use xml5ever::tendril::TendrilSink;

let dom = parse_document(RcDom::default(), Default::default()).one(
    r#"<root xml:lang="en" lang="en"/>"#,
);

assert!(dom.errors.borrow().is_empty());

Actual result: the parser reports: Duplicate attribute

Expected result: no parse error.

xml:lang and lang have different expanded
names; they are therefore distinct attributes under Namespaces in XML §6.3,
“Uniqueness of Attributes”
.

Example 2

That W3 spec has an example with similar duplicate attributes; it only fails if the order of attributes is reversed, meaning this is likely order dependent:

<!-- incorrectly rejected -->
<root xml:lang="en" lang="en"/>

<!-- currently accepted -->
<root lang="en" xml:lang="en"/>

Example 3

This also affects the WPT
html/rendering/non-replaced-elements/tables/table-align-float.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions