mirror of
https://github.com/lutris/lutris
synced 2024-09-05 15:33:40 +00:00
Do not parse registry lines that are too short and do not crash on invalid lines (Fixes #1168)
This commit is contained in:
parent
aa75690e0d
commit
60eacc78f6
|
@ -217,6 +217,11 @@ class WineRegistryKey(object):
|
|||
return "{0} {1}".format(self.raw_name, self.raw_timestamp)
|
||||
|
||||
def parse(self, line):
|
||||
"""Parse a registry line, populating meta and subkeys"""
|
||||
if len(line) < 4:
|
||||
# Line is too short, nothing to parse
|
||||
return
|
||||
|
||||
if line.startswith('#'):
|
||||
self.add_meta(line)
|
||||
elif line.startswith('"'):
|
||||
|
@ -224,12 +229,13 @@ class WineRegistryKey(object):
|
|||
key, value = re.split(re.compile(r"(?<![^\\]\\\")="), line, maxsplit=1)
|
||||
except ValueError as ex:
|
||||
logger.error("Unable to parse line %s", line)
|
||||
raise
|
||||
logger.exception(ex)
|
||||
return
|
||||
key = key[1:-1]
|
||||
self.subkeys[key] = value
|
||||
elif line.startswith('@'):
|
||||
k, v = line.split('=', 1)
|
||||
self.subkeys['default'] = v
|
||||
key, value = line.split('=', 1)
|
||||
self.subkeys['default'] = value
|
||||
|
||||
def add_to_last(self, line):
|
||||
last_subkey = list(self.subkeys.keys())[-1]
|
||||
|
|
Loading…
Reference in a new issue