Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etreeutils: sort attrs with matching namespaces by their NS URIs #91

Conversation

adamdecaf
Copy link
Contributor

In several of the XML Canonicalization specifications it states that attributes with matching namespaces need to be sorted by their Namespace URIs and not the prefixes.

However, the namespace URI was selected as the primary key because
this is closer to the intent of the Namespaces in XML specification,
which is to identify namespaces by URI and local name, not by a prefix
and local name.

The specifications call out that sorting by prefix is easier, but incorrect.

Further, the specifications state:

An element's attribute nodes are sorted lexicographically with
namespace URI as the primary key and local name as the secondary
key (an empty namespace URI is lexicographically least).

Sources:

In several of the XML Canonicalization specifications it states that
attributes with matching namespaces need to be sorted by their
Namespace URIs and not the prefixes.

> However, the namespace URI was selected as the primary key because
> this is closer to the intent of the Namespaces in XML specification,
> which is to identify namespaces by URI and local name, not by a prefix
> and local name.

The specifications call out that sorting by prefix is easier, but incorrect.

Further, the specifications state:

> An element's attribute nodes are sorted lexicographically with
> namespace URI as the primary key and local name as the secondary
> key (an empty namespace URI is lexicographically least).

Sources:

- https://www.w3.org/TR/xml-c14n11/#SortByNSURI
- https://www.w3.org/TR/2007/CR-xml-c14n11-20070621/#SortByNSURI
- https://www.w3.org/TR/2001/REC-xml-c14n-20010315#SortByNSURI
@adamdecaf
Copy link
Contributor Author

cc @russellhaering

@russellhaering
Copy link
Owner

Thanks for catching / fixing this, looks good!

@russellhaering russellhaering merged commit 32aee4e into russellhaering:main Apr 19, 2023
@adamdecaf adamdecaf deleted the sort-matching-attr-keys-by-ns-uri branch April 19, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants