handling malformed json (#12942)

This commit is contained in:
Davide Giacometti 2021-08-30 20:37:04 +02:00 committed by GitHub
parent 46bfd2cdac
commit d197ddeb15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -408,7 +408,14 @@ namespace ImageResizer.Properties
} }
string jsonData = _fileSystem.File.ReadAllText(SettingsPath); string jsonData = _fileSystem.File.ReadAllText(SettingsPath);
Settings jsonSettings = JsonSerializer.Deserialize<SettingsWrapper>(jsonData)?.Properties; var jsonSettings = new Settings();
try
{
jsonSettings = JsonSerializer.Deserialize<SettingsWrapper>(jsonData)?.Properties;
}
catch (JsonException)
{
}
// Needs to be called on the App UI thread as the properties are bound to the UI. // Needs to be called on the App UI thread as the properties are bound to the UI.
App.Current.Dispatcher.Invoke(() => App.Current.Dispatcher.Invoke(() =>