Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Safe parse h/w from public magicMetadata

Neeraj Guptaee1dbd7e8464
diff --git a/mobile/lib/models/metadata/file_magic.dart b/mobile/lib/models/metadata/file_magic.dart
index 6c146fa031..7599b7c82f 100644
--- a/mobile/lib/models/metadata/file_magic.dart
+++ b/mobile/lib/models/metadata/file_magic.dart
@@ -1,5 +1,6 @@
import "dart:convert";
+import "package:flutter/cupertino.dart";
import 'package:photos/models/metadata/common_keys.dart';
const editTimeKey = 'editedTime';
@@ -88,8 +89,8 @@ class PubMagicMetadata {
editedName: map[editNameKey],
caption: map[captionKey],
uploaderName: map[uploaderNameKey],
- w: map[widthKey],
- h: map[heightKey],
+ w: safeParseInt(map[widthKey], widthKey),
+ h: safeParseInt(map[heightKey], heightKey),
lat: map[latKey],
long: map[longKey],
mvi: map[motionVideoIndexKey],
@@ -97,4 +98,12 @@ class PubMagicMetadata {
mediaType: map[mediaTypeKey],
);
}
+
+ static int? safeParseInt(dynamic value, String key) {
+ if (value == null) return null;
+ if (value is int) return value;
+ debugPrint("PubMagicMetadata key: $key Unexpected value: $value");
+ if (value is String) return int.tryParse(value);
+ return null;
+ }
}