mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #2729 from pypeclub/bugfix/oiio_xml_parse_ampresand_values
General: Fix loading of unused chars in xml format
This commit is contained in:
commit
1b1c6145df
1 changed files with 14 additions and 0 deletions
|
|
@ -30,6 +30,9 @@ INT_TAGS = {
|
|||
"deep",
|
||||
"subimages",
|
||||
}
|
||||
|
||||
XML_CHAR_REF_REGEX_HEX = re.compile(r"&#x?[0-9a-fA-F]+;")
|
||||
|
||||
# Regex to parse array attributes
|
||||
ARRAY_TYPE_REGEX = re.compile(r"^(int|float|string)\[\d+\]$")
|
||||
|
||||
|
|
@ -191,6 +194,17 @@ def parse_oiio_xml_output(xml_string, logger=None):
|
|||
if not xml_string:
|
||||
return output
|
||||
|
||||
# Fix values with ampresand (lazy fix)
|
||||
# - oiiotool exports invalid xml which ElementTree can't handle
|
||||
# e.g. ""
|
||||
# WARNING: this will affect even valid character entities. If you need
|
||||
# those values correctly, this must take care of valid character ranges.
|
||||
# See https://github.com/pypeclub/OpenPype/pull/2729
|
||||
matches = XML_CHAR_REF_REGEX_HEX.findall(xml_string)
|
||||
for match in matches:
|
||||
new_value = match.replace("&", "&")
|
||||
xml_string = xml_string.replace(match, new_value)
|
||||
|
||||
if logger is None:
|
||||
logger = logging.getLogger("OIIO-xml-parse")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue