Skip to content

Commit ffefe07

Browse files
committed
refacotr: Updated the parseXMLString function to more closely follow the logic that previously existed
1 parent f76ec22 commit ffefe07

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plexapi/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@ def parseXMLString(s: str):
726726
""" Parse an XML string and return an ElementTree object. """
727727
if not s.strip():
728728
return None
729-
encoded_s = s.encode('utf-8')
730729
try: # Attempt to parse the string as-is without cleaning (which is expensive)
731-
return ElementTree.fromstring(encoded_s)
730+
return ElementTree.fromstring(s.encode('utf-8'))
732731
except ElementTree.ParseError: # If it fails, clean the string and try again
733-
return ElementTree.fromstring(cleanXMLString(encoded_s))
732+
cleaned_s = cleanXMLString(s).encode('utf-8')
733+
return ElementTree.fromstring(cleaned_s) if cleaned_s.strip() else None

0 commit comments

Comments
 (0)