Skip to content

Commit

Permalink
[FIX] odoo: parser recover True
Browse files Browse the repository at this point in the history
If the xml node has not ascci characters then it will raise a
tracebeack wgen running cleanup_xml_node method.

In this case the cleanup_xml_node should read the string using
a parser to try to recover the data and be able to generate
get the clean version of the node.
  • Loading branch information
zaoral committed Apr 29, 2024
1 parent 0fca7a5 commit 0925d0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion odoo/tools/xml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def cleanup_xml_node(xml_node_or_string, remove_blank_text=True, remove_blank_no
if isinstance(xml_node, str):
xml_node = xml_node.encode() # misnomer: fromstring actually reads bytes
if isinstance(xml_node, bytes):
xml_node = etree.fromstring(remove_control_characters(xml_node))
parser = etree.XMLParser(recover=True)
xml_node = etree.fromstring(remove_control_characters(xml_node), parser=parser)

# Process leaf nodes iteratively
# Depth-first, so any inner node may become a leaf too (if children are removed)
Expand Down

0 comments on commit 0925d0b

Please sign in to comment.