Skip to content

armgit / ente

Public Imported from GitHub
0

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

Harden malformed auth and API responses

Neeraj Guptaebad15d409a4
diff --git a/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart b/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
index 0f454772b2..dbed277630 100644
--- a/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
@@ -15,7 +15,7 @@ class BillingGateway {
///
/// Returns [BillingPlans] containing all available subscription plans.
Future<BillingPlans> getUserPlans() async {
- final response = await _enteDio.get("/billing/user-plans/");
+ final response = await _enteDio.get("/billing/user-plans");
return BillingPlans.fromMap(response.data);
}
diff --git a/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart b/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
index f337a700f1..681d740aed 100644
--- a/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
@@ -140,7 +140,7 @@ class FileDataGateway {
Future<({String encryptedData, String decryptionHeader})>
fetchSingleFileData({required int fileID, required String type}) async {
final response = await _enteDio.get(
- "/files/data/fetch/",
+ "/files/data/fetch",
queryParameters: {"fileID": fileID, "type": type},
);
return (
@@ -167,7 +167,7 @@ class FileDataGateway {
required Dio nonEnteDio,
}) async {
final response = await nonEnteDio.get(
- "$baseUrl/public-collection/files/data/fetch/",
+ "$baseUrl/public-collection/files/data/fetch",
queryParameters: {"fileID": fileID, "type": type},
options: Options(headers: headers),
);
diff --git a/mobile/apps/photos/lib/services/account/user_service.dart b/mobile/apps/photos/lib/services/account/user_service.dart
index 397f4bd4c0..45917c35ad 100644
--- a/mobile/apps/photos/lib/services/account/user_service.dart
+++ b/mobile/apps/photos/lib/services/account/user_service.dart
@@ -145,7 +145,10 @@ class UserService {
} on DioException catch (e) {
await dialog.hide();
_logger.info(e);
- final String? enteErrCode = e.response?.data["code"];
+ final responseData = e.response?.data;
+ final Object? enteErrCode = responseData is Map
+ ? responseData["code"]
+ : null;
if (enteErrCode != null && enteErrCode == "USER_ALREADY_REGISTERED") {
unawaited(
showAlertBottomSheet(
diff --git a/mobile/packages/accounts/lib/services/user_service.dart b/mobile/packages/accounts/lib/services/user_service.dart
index fe8b211049..22b2b3979e 100644
--- a/mobile/packages/accounts/lib/services/user_service.dart
+++ b/mobile/packages/accounts/lib/services/user_service.dart
@@ -119,7 +119,10 @@ class UserService {
} on DioException catch (e) {
await dialog.hide();
_logger.info(e);
- final String? enteErrCode = e.response?.data["code"];
+ final responseData = e.response?.data;
+ final Object? enteErrCode = responseData is Map
+ ? responseData["code"]
+ : null;
if (enteErrCode != null && enteErrCode == "USER_ALREADY_REGISTERED") {
unawaited(
showAlertBottomSheet(