You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During Xml parsing, attributes with an xml prefix ought to be associated with the xml namespace, even if such a namespace is not explicitly declared. According to https://www.w3.org/TR/REC-xml-names/#ns-decl :
The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace.
[/] Are you running the latest version of AngleSharp?
[/] Did you check the FAQs to see if that helps you?
[/] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
[/] Did you perform a search in the issues?
For more information, see the CONTRIBUTING guide.
Description
Xml prefixed attributes ought to be associated with the Xml namespace even if it has not been explicitly declared.
Steps to Reproduce
var xmlParser = new XmlParser();
var doc = xmlParser.ParseDocument("<xml xml:lang=\"en\">Test</xml>");
using (var stringWriter = new StringWriter()){
doc.ToHtml(stringWriter, new XhtmlMarkupFormatter());
stringWriter.ToString().Dump();
}
Expected behavior: Output should be <xml xml:lang=\"en\">Test</xml>
Actual behavior: Output is <xml lang="en">Test</xml>
Compare with the output to the following linqpad script
var xmlParser = new XmlParser();
var doc = xmlParser.ParseDocument("<xml xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" xml:lang=\"en\">Test</xml>");
using (var stringWriter = new StringWriter()){
doc.ToHtml(stringWriter, new XhtmlMarkupFormatter());
stringWriter.ToString().Dump();
}
Bug Report
During Xml parsing, attributes with an
xml
prefix ought to be associated with the xml namespace, even if such a namespace is not explicitly declared. According to https://www.w3.org/TR/REC-xml-names/#ns-decl :Prerequisites
AngleSharp.Css
for CSS support)For more information, see the
CONTRIBUTING
guide.Description
Xml prefixed attributes ought to be associated with the Xml namespace even if it has not been explicitly declared.
Steps to Reproduce
Expected behavior: Output should be
<xml xml:lang=\"en\">Test</xml>
Actual behavior: Output is
<xml lang="en">Test</xml>
Compare with the output to the following linqpad script
Output:
<xml xmlns:="http://www.w3.org/XML/1998/namespace" xml:lang="en">Test</xml>
Environment details: Win 10; .NET 6.0.15
Possible Solution
In the
XmlDomBuilder
we need to replace this code:with this:
A PR can be made to this effect with a test by which I confirmed the bug and solution.
The text was updated successfully, but these errors were encountered: