Skip to content

Commit

Permalink
Merge pull request #1822 from NicolasBuquet/develop
Browse files Browse the repository at this point in the history
Prevent crash when sending file with unrecognised file extension (no …
  • Loading branch information
stefanceriu authored Sep 29, 2023
2 parents 626e03f + 3bed914 commit 00a864b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ - (MXHTTPOperation*)sendImage:(NSData*)imageData
kMXMessageBodyKey: filename,
@"url": fakeMediaURI,
@"info": [@{
@"mimetype": mimetype,
@"mimetype": (mimeType ?: @"application/octet-stream"),
@"w": @(imageSize.width),
@"h": @(imageSize.height),
@"size": @(imageData.length)
Expand Down Expand Up @@ -1347,7 +1347,7 @@ - (MXHTTPOperation*)sendVideoAsset:(AVAsset*)videoAsset
}

// update metadata with result of converter output
msgContent[@"info"][@"mimetype"] = mimetype;
msgContent[@"info"][@"mimetype"] = (mimeType ?: @"application/octet-stream");
msgContent[@"info"][@"w"] = @(size.width);
msgContent[@"info"][@"h"] = @(size.height);
msgContent[@"info"][@"duration"] = @((int)floor(durationInMs));
Expand Down Expand Up @@ -1670,15 +1670,15 @@ - (MXHTTPOperation*)_sendFile:(NSURL*)fileLocalURL
kMXMessageBodyKey: filename,
@"url": fakeMediaURI,
@"info": @{
@"mimetype": mimeType,
@"mimetype": (mimeType ?: @"application/octet-stream"),
@"size": @(fileData.length)
},
kMXMessageContentKeyExtensibleTextMSC1767: filename,
kMXMessageContentKeyExtensibleFileMSC1767: @{
kMXMessageContentKeyExtensibleFileSize: @(fileData.length),
kMXMessageContentKeyExtensibleFileName: filename,
kMXMessageContentKeyExtensibleFileURL: fakeMediaURI,
kMXMessageContentKeyExtensibleFileMimeType: mimeType
kMXMessageContentKeyExtensibleFileMimeType: (mimeType ?: @"application/octet-stream")
}.mutableCopy}.mutableCopy;

if(additionalTypes.count)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/mimetype.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent crash when sending file with unrecognised file extension (no associated mime type)

0 comments on commit 00a864b

Please sign in to comment.