[Requests] Make sure to not use the latin1 version of the json but instead convert the bytes to utf8 as required by various RFCs.
Took 14 minutes
This commit is contained in:
parent
f4c8cfe992
commit
9f6bd740ca
|
@ -18,13 +18,14 @@
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:famedlysdk/matrix_api/model/filter.dart';
|
import 'package:famedlysdk/matrix_api/model/filter.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/keys_query_response.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/login_types.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/notifications_query_response.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/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/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/server_capabilities.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/supported_versions.dart';
|
import 'package:famedlysdk/matrix_api/model/supported_versions.dart';
|
||||||
import 'package:famedlysdk/matrix_api/model/sync_update.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 'package:moor/moor.dart';
|
||||||
|
|
||||||
import 'model/device.dart';
|
import 'model/device.dart';
|
||||||
import 'model/matrix_event.dart';
|
|
||||||
import 'model/matrix_keys.dart';
|
|
||||||
import 'model/event_context.dart';
|
import 'model/event_context.dart';
|
||||||
import 'model/events_sync_update.dart';
|
import 'model/events_sync_update.dart';
|
||||||
import 'model/login_response.dart';
|
import 'model/login_response.dart';
|
||||||
|
import 'model/matrix_event.dart';
|
||||||
import 'model/matrix_exception.dart';
|
import 'model/matrix_exception.dart';
|
||||||
|
import 'model/matrix_keys.dart';
|
||||||
import 'model/one_time_keys_claim_response.dart';
|
import 'model/one_time_keys_claim_response.dart';
|
||||||
import 'model/open_id_credentials.dart';
|
import 'model/open_id_credentials.dart';
|
||||||
import 'model/presence_content.dart';
|
import 'model/presence_content.dart';
|
||||||
|
@ -192,7 +193,8 @@ class MatrixApi {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var jsonString = String.fromCharCodes(resp.body.runes);
|
var resp_body = utf8.decode(resp.bodyBytes);
|
||||||
|
var jsonString = String.fromCharCodes(resp_body.runes);
|
||||||
if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
|
if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
|
||||||
jsonString = '\{"chunk":$jsonString\}';
|
jsonString = '\{"chunk":$jsonString\}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
|
|
||||||
|
import 'package:famedlysdk/encryption.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:famedlysdk/matrix_api.dart';
|
import 'package:famedlysdk/matrix_api.dart';
|
||||||
import 'package:famedlysdk/encryption.dart';
|
|
||||||
import 'package:famedlysdk/src/room.dart';
|
import 'package:famedlysdk/src/room.dart';
|
||||||
import 'package:famedlysdk/src/utils/device_keys_list.dart';
|
import 'package:famedlysdk/src/utils/device_keys_list.dart';
|
||||||
import 'package:famedlysdk/src/utils/matrix_file.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:http/http.dart' as http;
|
||||||
import 'package:pedantic/pedantic.dart';
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
|
||||||
|
import 'database/database.dart' show Database;
|
||||||
import 'event.dart';
|
import 'event.dart';
|
||||||
import 'room.dart';
|
import 'room.dart';
|
||||||
|
import 'user.dart';
|
||||||
import 'utils/event_update.dart';
|
import 'utils/event_update.dart';
|
||||||
import 'utils/room_update.dart';
|
import 'utils/room_update.dart';
|
||||||
import 'user.dart';
|
|
||||||
import 'database/database.dart' show Database;
|
|
||||||
|
|
||||||
typedef RoomSorter = int Function(Room a, Room b);
|
typedef RoomSorter = int Function(Room a, Room b);
|
||||||
|
|
||||||
|
@ -231,7 +231,8 @@ class Client {
|
||||||
) async {
|
) async {
|
||||||
final response = await http
|
final response = await http
|
||||||
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
||||||
final rawJson = json.decode(response.body);
|
var resp_body = utf8.decode(response.bodyBytes);
|
||||||
|
final rawJson = json.decode(resp_body);
|
||||||
return WellKnownInformations.fromJson(rawJson);
|
return WellKnownInformations.fromJson(rawJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue