Skip to content

Fix GH-10234: Setting DOMAttr::textContent results in an empty attribute value #10245

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

Closed
wants to merge 2 commits into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jan 6, 2023

Fixes GH-10234

We can't directly call xmlNodeSetContent, because it might encode the string
through xmlStringLenGetNodeList for types
XML_DOCUMENT_FRAG_NODE, XML_ELEMENT_NODE, XML_ATTRIBUTE_NODE.
In these cases we need to use a text node to avoid the encoding.
For the other cases, we can rely on xmlNodeSetContent because it is either
a no-op, or handles the content without encoding and clears the properties
field if needed.

…ribute value.

We can't directly call xmlNodeSetContent, because it might encode the string
through xmlStringLenGetNodeList for types
XML_DOCUMENT_FRAG_NODE, XML_ELEMENT_NODE, XML_ATTRIBUTE_NODE.
In these cases we need to use a text node to avoid the encoding.
For the other cases, we *can* rely on xmlNodeSetContent because it is either
a no-op, or handles the content without encoding and clears the properties
field if needed.

The test was taken from the issue report, for the test:
Co-authored-by: ThomasWeinert <[email protected]>

Closes phpGH-10245.
@nielsdos
Copy link
Member Author

nielsdos commented May 6, 2023

Rebased this and added some more testing. Is there someone who's able to review this? :)

@iluuu1994
Copy link
Member

Maybe @Girgias?

@Girgias
Copy link
Member

Girgias commented May 10, 2023

@beberlei has done some stuff on DOM IIRC. I will try and have a look if they don't respond quickly.

@nielsdos nielsdos requested a review from Girgias May 22, 2023 21:44
@beberlei
Copy link
Contributor

I have honestly lost the grasp of libxml understandering at some point, it took me a few weeks to get into it the last time. I see this change has all the test assertions so from that perspective 😀

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just approve, worst case someone will report a new bug :D

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.

4 participants