JsonApi: check that the Settings actually exist

This commit is contained in:
Robin C. Ladiges 2022-09-05 04:10:15 +02:00
parent 92e540aaa6
commit c81f6aaf96
No known key found for this signature in database
GPG Key ID: B494D3DF92661B99
1 changed files with 8 additions and 1 deletions

View File

@ -49,7 +49,12 @@ public static class ApiRequestStatus {
output.TryGetValue(key, out next);
// traverse down the Settings object
input = input.GetType().GetProperty(key).GetValue(input, null);
var prop = input.GetType().GetProperty(key);
if (prop == null) {
JsonApi.Logger.Warn($"Property \"{allowedSetting}\" doesn't exist on the Settings object. This is probably a misconfiguration in the settings.json");
goto next;
}
input = prop.GetValue(input, null);
}
if (lastKey != "") {
@ -57,6 +62,8 @@ public static class ApiRequestStatus {
output.Remove(lastKey);
output.Add(lastKey, input);
}
next:;
}
return settings;