fix: Don't trust the info block of events

This commit is contained in:
Sorunome 2020-09-10 11:10:38 +02:00
parent 5d45c224a3
commit e08f35b5d0
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 3 additions and 1 deletions

View File

@ -406,7 +406,7 @@ class Event extends MatrixEvent {
// Is this file storeable?
final infoMap =
getThumbnail ? content['info']['thumbnail_info'] : content['info'];
final storeable = room.client.database != null &&
var storeable = room.client.database != null &&
infoMap is Map<String, dynamic> &&
infoMap['size'] is int &&
infoMap['size'] <= room.client.database.maxFileSize;
@ -422,6 +422,8 @@ class Event extends MatrixEvent {
};
uint8list =
await downloadCallback(mxContent.getDownloadLink(room.client));
storeable = storeable &&
uint8list.lengthInBytes < room.client.database.maxFileSize;
if (storeable) {
await room.client.database
.storeFile(mxContent.toString(), uint8list, DateTime.now());