diff --git a/api/lib/src/models/data.dart b/api/lib/src/models/data.dart index 7ee002caacd7..7425f212ef56 100644 --- a/api/lib/src/models/data.dart +++ b/api/lib/src/models/data.dart @@ -174,9 +174,13 @@ final class NoteData extends ArchiveData { if (data == null) { return null; } - final content = utf8.decode(data); - final json = jsonDecode(content) as Map; - return DocumentPage.fromJson(json); + try { + final content = utf8.decode(data); + final json = jsonDecode(content) as Map; + return DocumentPage.fromJson(json); + } catch (e) { + return null; + } } @useResult @@ -280,8 +284,12 @@ final class NoteData extends ArchiveData { return null; } final content = utf8.decode(data); - final json = jsonDecode(content) as Map; - return DocumentInfo.fromJson(json); + try { + final json = jsonDecode(content) as Map; + return DocumentInfo.fromJson(json); + } catch (e) { + return null; + } } @useResult @@ -303,7 +311,11 @@ final class NoteData extends ArchiveData { if (data == null) { return null; } - return NoteData.fromData(data); + try { + return NoteData.fromData(data); + } catch (e) { + return null; + } } @useResult @@ -333,9 +345,13 @@ final class NoteData extends ArchiveData { if (data == null) { return null; } - final content = utf8.decode(data); - final json = jsonDecode(content) as Map; - return ButterflyComponent.fromJson(json); + try { + final content = utf8.decode(data); + final json = jsonDecode(content) as Map; + return ButterflyComponent.fromJson(json); + } catch (e) { + return null; + } } @useResult @@ -356,9 +372,13 @@ final class NoteData extends ArchiveData { if (data == null) { return null; } - final content = utf8.decode(data); - final json = jsonDecode(content) as Map; - return TextStyleSheet.fromJson(json); + try { + final content = utf8.decode(data); + final json = jsonDecode(content) as Map; + return TextStyleSheet.fromJson(json); + } catch (e) { + return null; + } } @useResult @@ -392,9 +412,13 @@ final class NoteData extends ArchiveData { if (data == null) { return null; } - final content = utf8.decode(data); - final json = jsonDecode(content) as Map; - return ColorPalette.fromJson(json); + try { + final content = utf8.decode(data); + final json = jsonDecode(content) as Map; + return ColorPalette.fromJson(json); + } catch (e) { + return null; + } } @useResult diff --git a/app/pubspec.lock b/app/pubspec.lock index e8f61e17070b..390dd3bea1ec 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -177,10 +177,10 @@ packages: dependency: transitive description: name: camera_android_camerax - sha256: abcfa1ac32bd03116b4cfda7e8223ab391f01966e65823c064afe388550d1b3d + sha256: ecadc214daed34d8503540525d26577731c066f1993c254aa5272da7629e8f10 url: "https://pub.dev" source: hosted - version: "0.6.10+3" + version: "0.6.12" camera_avfoundation: dependency: transitive description: @@ -193,10 +193,10 @@ packages: dependency: transitive description: name: camera_platform_interface - sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061 + sha256: "953e7baed3a7c8fae92f7200afeb2be503ff1a17c3b4e4ed7b76f008c2810a31" url: "https://pub.dev" source: hosted - version: "2.8.0" + version: "2.9.0" camera_web: dependency: transitive description: @@ -570,10 +570,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123" + sha256: c200fd79c918a40c5cd50ea0877fa13f81bdaf6f0a5d3dbcc2a13e3285d6aa1b url: "https://pub.dev" source: hosted - version: "2.0.16" + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter @@ -1120,10 +1120,10 @@ packages: dependency: transitive description: name: pubspec_parse - sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0" + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.5.0" qr: dependency: transitive description: @@ -1518,10 +1518,10 @@ packages: dependency: transitive description: name: vector_graphics_codec - sha256: "2430b973a4ca3c4dbc9999b62b8c719a160100dcbae5c819bae0cacce32c9cdb" + sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" url: "https://pub.dev" source: hosted - version: "1.1.12" + version: "1.1.13" vector_graphics_compiler: dependency: transitive description: diff --git a/metadata/en-US/changelogs/128.txt b/metadata/en-US/changelogs/128.txt index a75be6143d98..277c6d7a0614 100644 --- a/metadata/en-US/changelogs/128.txt +++ b/metadata/en-US/changelogs/128.txt @@ -1,5 +1,6 @@ This is a hotfix update, cherry picking some important fixes from the last 2.3.0-beta.0 nightly release. +* Add error boundaries for corrupted files * Fix default stroke width ([#779](https://github.com/LinwoodDev/Butterfly/issues/779)) * Fix svg export shows wrong initial preset * Fix capture thumbnail uses wrong position