Fix pre-commit

This commit is contained in:
Twangboy 2025-01-22 13:50:00 -07:00 committed by Daniel Wozniak
parent 3d3d6d6e22
commit a059ff4bfd

View file

@ -5060,6 +5060,7 @@ def _remove_invalid_xmlns(xml_file):
xml_tree = lxml.etree.parse(io.StringIO(modified_xml))
return xml_tree
def _encode_xmlns_url(match):
"""
Escape spaces in xmlns urls
@ -5068,9 +5069,10 @@ def _encode_xmlns_url(match):
xmlns = match.group(2)
url = match.group(3)
after_url = match.group(4)
encoded_url = re.sub(r'\s+', '%20', url)
encoded_url = re.sub(r"\s+", "%20", url)
return f'{before_xmlns}{xmlns}="{encoded_url}"{after_url}'
def _parse_xml(adm_file):
"""
Parse the admx/adml file. There are 3 scenarios (so far) that we'll likely
@ -5118,7 +5120,11 @@ def _parse_xml(adm_file):
raw = raw.decode(encoding)
for line in raw.split("\r\n"):
if 'xmlns="' in line:
line = re.sub(r'(.*)(\bxmlns(?::\w+)?)\s*=\s*"([^"]+)"(.*)', _encode_xmlns_url, line)
line = re.sub(
r'(.*)(\bxmlns(?::\w+)?)\s*=\s*"([^"]+)"(.*)',
_encode_xmlns_url,
line,
)
if 'key="' in line:
start = line.index('key="')
q1 = line[start:].index('"') + start