diff --git a/openpype/lib/transcoding.py b/openpype/lib/transcoding.py index 36f6858a78f..e89fa6331e1 100644 --- a/openpype/lib/transcoding.py +++ b/openpype/lib/transcoding.py @@ -30,6 +30,9 @@ "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")