mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-07 02:28:50 +00:00
config: don't crash with a config file containing only comments
This commit is contained in:
parent
06cb68c799
commit
d95f28e6bf
@ -432,6 +432,8 @@ def parse(text):
|
|||||||
raise exceptions.OptionsError("Could not parse options.")
|
raise exceptions.OptionsError("Could not parse options.")
|
||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
raise exceptions.OptionsError("Config error - no keys found.")
|
raise exceptions.OptionsError("Config error - no keys found.")
|
||||||
|
elif data is None:
|
||||||
|
return {}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,6 +257,10 @@ def test_serialize():
|
|||||||
with pytest.raises(Exception, match="Config error"):
|
with pytest.raises(Exception, match="Config error"):
|
||||||
optmanager.load(o2, t)
|
optmanager.load(o2, t)
|
||||||
|
|
||||||
|
t = "# a comment"
|
||||||
|
optmanager.load(o2, t)
|
||||||
|
assert optmanager.load(o2, "foobar: '123'") == {"foobar": "123"}
|
||||||
|
|
||||||
t = ""
|
t = ""
|
||||||
optmanager.load(o2, t)
|
optmanager.load(o2, t)
|
||||||
assert optmanager.load(o2, "foobar: '123'") == {"foobar": "123"}
|
assert optmanager.load(o2, "foobar: '123'") == {"foobar": "123"}
|
||||||
|
Loading…
Reference in New Issue
Block a user