Skip to content

Avoid libxml2's xmlNodeSetContent #19189

@nwellnhof

Description

@nwellnhof

Description

xmlNodeSetContent decodes character and entity references which is typically not what users expect. This can be worked around by first calling xmlNodeSetContent with a NULL pointer to clear the node and then using xmlNodeAddContent which adds the string verbatim.

Here's an example:

<?php
$doc = new DOMDocument();
$doc->loadXML("<!DOCTYPE doc [ <!ENTITY e 'ent'> ]><doc/>");
$root = $doc->documentElement;
$root->nodeValue = "&lt; &e; &gt;";
echo($root->nodeValue); # prints "< ent >"

PHP Version

All versions

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy