π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Safely parse faceBoxJson
Neeraj Gupta672e21d5dc4d
diff --git a/mobile/lib/models/ml/face/box.dart b/mobile/lib/models/ml/face/box.dartindex 3c5be3f9f3..d5d8672fb9 100644--- a/mobile/lib/models/ml/face/box.dart+++ b/mobile/lib/models/ml/face/box.dart@@ -1,3 +1,5 @@+import "package:photos/utils/parse.dart";+/// Bounding box of a face.////// [ x] and [y] are the minimum coordinates, so the top left corner of the box.@@ -19,10 +21,12 @@ class FaceBox {factory FaceBox.fromJson(Map<String, dynamic> json) {return FaceBox(- x: (json['x'] as double?) ?? (json['xMin'] as double),- y: (json['y'] as double?) ?? (json['yMin'] as double),- width: json['width'] as double,- height: json['height'] as double,+ x: parseIntOrDoubleAsDouble(json['x']) ??+ parseIntOrDoubleAsDouble(json['xMin'])!,+ y: parseIntOrDoubleAsDouble(json['y']) ??+ parseIntOrDoubleAsDouble(json['yMin'])!,+ width: parseIntOrDoubleAsDouble(json['width'])!,+ height: parseIntOrDoubleAsDouble(json['height'])!,);}diff --git a/mobile/lib/utils/parse.dart b/mobile/lib/utils/parse.dartindex 5eb39d3cb1..156b9fbd97 100644--- a/mobile/lib/utils/parse.dart+++ b/mobile/lib/utils/parse.dart@@ -1,7 +1,7 @@double? parseIntOrDoubleAsDouble(dynamic value) {if (value == null) return null;- if (value is int) return value * 1.0;if (value is double) return value;+ if (value is int) return value * 1.0;return null;}