Skip to content

LIBXML_NSCLEAN and DTD entities with namespaced attributes #315

Description

@alfsb

While doing some optimization experiments on doc-base/configure.php, I tried to add LIBXML_NSCLEAN before first DOMDocument->load(). This caused 173 validating failures, all related to the href attribute on Jing. libxml2 simply refused the file. All failures are like this:

doc-base/temp/manual.xml:18673:62: error: attribute "href" not allowed here; expected attribute [...] or an attribute from another namespace

manual.xml:18673:62 is something like

 builds from <link href="https://www.php.net/downloads.php">the official download

This, in turn is part of DTD entity

<!ENTITY warn.install.third-party-support '<warning xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<simpara>
Builds from third-parties are considered unofficial and not directly
supported by the PHP project. Any bugs encountered should be reported to the
provider of those unofficial builds unless they can be reproduced using the
builds from <link xlink:href="&url.php.downloads;">the official download
area</link>.
</simpara>
</warning>'>

The only thing that caught my eye is that xmlns:xlink="http://www.w3.org/1999/xlink" is declared at the "root" of entity, whereas other entities declares this namespace in the <link> element itself. But changing the positions, or adding the namespace in both places changed nothing.

The first difference between XMLs assembled with and without LIBXML_NSCLEAN, are:

< builds from <link xlink:href="https://www.php.net/downloads.php">the official download
> builds from <link href="https://www.php.net/downloads.php">the official download

This means that the LIBXML_NSCLEAN option removed the XML declarations from <simpara> (correctly), but also removed the xmlns prefix of href attribute, that appears to be incorrect, IMHO.

I do not know the XML spec by the letter, so I do not know if it is expected or if I hit a bug.

Specifically, I do not know if the parsing of namespaces of attributes can or should be treated differently, when inside a DTD entity.

This is on PHP 8.1.2-1ubuntu2.24, libxml 2.9.13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions