-
Notifications
You must be signed in to change notification settings - Fork 233
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
xml5ever drops xml attributes with matching namespace and local names #538
Comments
Unfortunately, there seems to be a bug with xml5ever that drops namespaced attributes, I've raised a bug servo/html5ever#538
I've just hit this exact issue when parsing this PECL API response: <?xml version="1.0" encoding="UTF-8"?>
<r xmlns="http://pear.php.net/dtd/rest.release" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.release http://pear.php.net/dtd/rest.release.xsd">
<p xlink:href="/rest/p/protobuf">protobuf</p>
<c>pecl.php.net</c>
<v>4.27.0</v>
<st>stable</st>
<l>BSD-3-Clause</l>
<m>protobufpackages</m>
<s>Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.</s>
<d>https://developers.google.com/protocol-buffers/</d>
<da>2024-05-23 14:46:50</da>
<n>* See github.com/protocolbuffers/protobuf/releases/tag/v27.0 for release notes.</n>
<f>243961</f>
<g>https://pecl.php.net/get/protobuf-4.27.0</g>
<x xlink:href="package.4.27.0.xml"/>
</r> The |
This comment was marked as outdated.
This comment was marked as outdated.
https://github.com/servo/html5ever/blob/main/xml5ever/src/tree_builder/mod.rs#L341-L349 is the check that filters out subsequent attributes. This happens because of this duplicate attribute check: https://github.com/servo/html5ever/blob/main/xml5ever/src/tree_builder/mod.rs#L316 |
This was introduced in baeacb4 but the original repo's related issue is no longer visible: https://github.com/Ygg01/xml5ever/issues/30 |
Thank you @jdm I confirm that it worked. Patching my local dependencies to use the commit in #539, I can properly parse the response, including the last link:
|
Hey @jdm are there any plans to update the dependencies of markup5ever_rcdom to include the fixes? edit: Just found there's a verion <!-- before -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd">
<sodipodi:namedview>
...
</sodipodi:namedview>
<path d="..." sodipodi:nodetypes="cccc"/>
</svg>
<!-- after: xmlns:sodipodi moved to child -->
<svg xmlns="http://www.w3.org/2000/svg">
<sodipodi:namedview xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd">
...
</sodipodi:namedview>
<path d="..." sodipodi:nodetypes="cccc"></path>
</svg> <!-- before -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd">
<path d="..." sodipodi:nodetypes="cccc"/>
</svg>
<!-- after: xmlns:sodipodi removed entirely -->
<svg xmlns="http://www.w3.org/2000/svg">
<path d="..." sodipodi:nodetypes="cccc"></path>
</svg> |
The published rcdom crates are not owned by the html5ever developers. |
Oh that's good to know. I think this issue may be coming from the parsing step, which in the example I gave uses xml5ever 0.20.0 and markup5ever 0.14 the example is based similarly on the original comment (#538 (comment)) |
@jdm will this issue be re-opened this issue based on my last comment? I don't think the root xmlns'd attributes should be removed if the specified namespace is used as a prefix by descendants. |
Hey there, I've run into this issue recently where only one attribute of a given namespace and local name will remain in the document. Consider the following test
The output for me is as follows
As you can see, all the
x:href
attributes, except for the first, seem to be dropped completely.This doesn't seem like expected behaviour unless I'm missing something.
If needed, this are the versions I'm using
The text was updated successfully, but these errors were encountered: