mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
escape spaces found while parsing GPO XMLNS tags
This commit is contained in:
parent
c4a1a6eeba
commit
a887a0000b
1 changed files with 12 additions and 0 deletions
|
@ -5060,6 +5060,16 @@ def _remove_invalid_xmlns(xml_file):
|
||||||
xml_tree = lxml.etree.parse(io.StringIO(modified_xml))
|
xml_tree = lxml.etree.parse(io.StringIO(modified_xml))
|
||||||
return xml_tree
|
return xml_tree
|
||||||
|
|
||||||
|
def _encode_xmlns_url(match):
|
||||||
|
"""
|
||||||
|
Escape spaces in xmlns urls
|
||||||
|
"""
|
||||||
|
before_xmlns = match.group(1)
|
||||||
|
xmlns = match.group(2)
|
||||||
|
url = match.group(3)
|
||||||
|
after_url = match.group(4)
|
||||||
|
encoded_url = re.sub(r'\s+', '%20', url)
|
||||||
|
return f'{before_xmlns}{xmlns}="{encoded_url}"{after_url}'
|
||||||
|
|
||||||
def _parse_xml(adm_file):
|
def _parse_xml(adm_file):
|
||||||
"""
|
"""
|
||||||
|
@ -5107,6 +5117,8 @@ def _parse_xml(adm_file):
|
||||||
encoding = "utf-16"
|
encoding = "utf-16"
|
||||||
raw = raw.decode(encoding)
|
raw = raw.decode(encoding)
|
||||||
for line in raw.split("\r\n"):
|
for line in raw.split("\r\n"):
|
||||||
|
if 'xmlns="' in line:
|
||||||
|
line = re.sub(r'(.*)(\bxmlns(?::\w+)?)\s*=\s*"([^"]+)"(.*)', _encode_xmlns_url, line)
|
||||||
if 'key="' in line:
|
if 'key="' in line:
|
||||||
start = line.index('key="')
|
start = line.index('key="')
|
||||||
q1 = line[start:].index('"') + start
|
q1 = line[start:].index('"') + start
|
||||||
|
|
Loading…
Add table
Reference in a new issue