mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +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:
parent
9f8d518e82
commit
c1d67d6b17
1 changed files with 4 additions and 1 deletions
|
@ -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 rows = object.get("rows").to_u32(default_row_count);
|
||||||
auto columns = object.get("columns");
|
auto columns = object.get("columns");
|
||||||
auto name = object.get("name").as_string_or("Sheet");
|
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);
|
sheet->set_name(name);
|
||||||
|
|
||||||
|
@ -402,7 +406,6 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
||||||
sheet->add_column();
|
sheet->add_column();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cells = object.get("cells").as_object();
|
|
||||||
auto json = sheet->interpreter().global_object().get("JSON");
|
auto json = sheet->interpreter().global_object().get("JSON");
|
||||||
auto& parse_function = json.as_object().get("parse").as_function();
|
auto& parse_function = json.as_object().get("parse").as_function();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue