mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Refs #36769 -- Avoided visiting grandchild nodes in XML Deserializer.
The only use case for visiting grandchild nodes turned out to be to
support an unintentionally invalid fixture in the test suite.
The invalid fixture added in #36969 was modeled on fixture9.xml in
dae08cf55b, so that is corrected as well
in this commit, where the test will still pass.
This commit is contained in:
@@ -439,17 +439,13 @@ class Deserializer(base.Deserializer):
|
||||
)
|
||||
|
||||
|
||||
def check_element_type(element):
|
||||
return element.nodeType in (element.TEXT_NODE, element.CDATA_SECTION_NODE)
|
||||
|
||||
|
||||
def getInnerText(node):
|
||||
"""Get the inner text of a DOM node and any children one level deep."""
|
||||
# inspired by
|
||||
# https://mail.python.org/pipermail/xml-sig/2005-March/011022.html
|
||||
return "".join(
|
||||
[
|
||||
element.data
|
||||
for child in node.childNodes
|
||||
for element in (child, *child.childNodes)
|
||||
if element.nodeType in (element.TEXT_NODE, element.CDATA_SECTION_NODE)
|
||||
]
|
||||
[child.data for child in node.childNodes if check_element_type(child)]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<object pk="1" model="fixtures.person">
|
||||
<field type="CharField" name="name">
|
||||
<natural>Django <em>pony</em></natural>
|
||||
Django <em>pony</em>
|
||||
</field>
|
||||
</object>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user