Merge branch 'MTRNord/utf-8-decode-json' into 'master'
[Requests] Make sure to not use the latin1 version of the json but instead... See merge request famedly/famedlysdk!391
This commit is contained in:
commit
bf1a4fe91b
|
@ -18,13 +18,14 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:famedlysdk/matrix_api/model/filter.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/keys_query_response.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/login_types.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/notifications_query_response.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/open_graph_data.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/request_token_response.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/profile.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/request_token_response.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/server_capabilities.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/supported_versions.dart';
|
||||
import 'package:famedlysdk/matrix_api/model/sync_update.dart';
|
||||
|
@ -36,12 +37,12 @@ import 'package:mime/mime.dart';
|
|||
import 'package:moor/moor.dart';
|
||||
|
||||
import 'model/device.dart';
|
||||
import 'model/matrix_event.dart';
|
||||
import 'model/matrix_keys.dart';
|
||||
import 'model/event_context.dart';
|
||||
import 'model/events_sync_update.dart';
|
||||
import 'model/login_response.dart';
|
||||
import 'model/matrix_event.dart';
|
||||
import 'model/matrix_exception.dart';
|
||||
import 'model/matrix_keys.dart';
|
||||
import 'model/one_time_keys_claim_response.dart';
|
||||
import 'model/open_id_credentials.dart';
|
||||
import 'model/presence_content.dart';
|
||||
|
@ -192,7 +193,13 @@ class MatrixApi {
|
|||
);
|
||||
break;
|
||||
}
|
||||
var jsonString = String.fromCharCodes(resp.body.runes);
|
||||
var respBody = resp.body;
|
||||
try {
|
||||
respBody = utf8.decode(resp.bodyBytes);
|
||||
} catch (_) {
|
||||
// No-OP
|
||||
}
|
||||
var jsonString = String.fromCharCodes(respBody.runes);
|
||||
if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
|
||||
jsonString = '\{"chunk":$jsonString\}';
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:famedlysdk/src/room.dart';
|
||||
import 'package:famedlysdk/src/utils/device_keys_list.dart';
|
||||
import 'package:famedlysdk/src/utils/matrix_file.dart';
|
||||
|
@ -30,12 +30,12 @@ import 'package:famedlysdk/src/utils/to_device_event.dart';
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import 'database/database.dart' show Database;
|
||||
import 'event.dart';
|
||||
import 'room.dart';
|
||||
import 'user.dart';
|
||||
import 'utils/event_update.dart';
|
||||
import 'utils/room_update.dart';
|
||||
import 'user.dart';
|
||||
import 'database/database.dart' show Database;
|
||||
|
||||
typedef RoomSorter = int Function(Room a, Room b);
|
||||
|
||||
|
@ -231,7 +231,13 @@ class Client {
|
|||
) async {
|
||||
final response = await http
|
||||
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
||||
final rawJson = json.decode(response.body);
|
||||
var respBody = response.body;
|
||||
try {
|
||||
respBody = utf8.decode(response.bodyBytes);
|
||||
} catch (_) {
|
||||
// No-OP
|
||||
}
|
||||
final rawJson = json.decode(respBody);
|
||||
return WellKnownInformations.fromJson(rawJson);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue