1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:38:10 +00:00

Spreadsheet: Don't assume that the 'cells' field is an object

It might be missing, or not be an object.
Fixes #4821.
This commit is contained in:
AnotherTest 2021-03-18 21:07:51 +03:30 committed by Andreas Kling
parent 9f8d518e82
commit c1d67d6b17

View file

@ -383,6 +383,10 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
auto rows = object.get("rows").to_u32(default_row_count);
auto columns = object.get("columns");
auto name = object.get("name").as_string_or("Sheet");
auto cells_value = object.get_or("cells", JsonObject {});
if (!cells_value.is_object())
return nullptr;
auto& cells = cells_value.as_object();
sheet->set_name(name);
@ -402,7 +406,6 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
sheet->add_column();
}
auto cells = object.get("cells").as_object();
auto json = sheet->interpreter().global_object().get("JSON");
auto& parse_function = json.as_object().get("parse").as_function();