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)
|
return "{0} {1}".format(self.raw_name, self.raw_timestamp)
|
||||||
|
|
||||||
def parse(self, line):
|
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('#'):
|
if line.startswith('#'):
|
||||||
self.add_meta(line)
|
self.add_meta(line)
|
||||||
elif line.startswith('"'):
|
elif line.startswith('"'):
|
||||||
|
@ -224,12 +229,13 @@ class WineRegistryKey(object):
|
||||||
key, value = re.split(re.compile(r"(?<![^\\]\\\")="), line, maxsplit=1)
|
key, value = re.split(re.compile(r"(?<![^\\]\\\")="), line, maxsplit=1)
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
logger.error("Unable to parse line %s", line)
|
logger.error("Unable to parse line %s", line)
|
||||||
raise
|
logger.exception(ex)
|
||||||
|
return
|
||||||
key = key[1:-1]
|
key = key[1:-1]
|
||||||
self.subkeys[key] = value
|
self.subkeys[key] = value
|
||||||
elif line.startswith('@'):
|
elif line.startswith('@'):
|
||||||
k, v = line.split('=', 1)
|
key, value = line.split('=', 1)
|
||||||
self.subkeys['default'] = v
|
self.subkeys['default'] = value
|
||||||
|
|
||||||
def add_to_last(self, line):
|
def add_to_last(self, line):
|
||||||
last_subkey = list(self.subkeys.keys())[-1]
|
last_subkey = list(self.subkeys.keys())[-1]
|
||||||
|
|
Loading…
Reference in a new issue