Skip to content

Commit

Permalink
Merge pull request #7429 from vector-im/manu/7406_m_file_format
Browse files Browse the repository at this point in the history
Manage bad m.file attachment format
  • Loading branch information
manuroe authored Mar 16, 2023
2 parents 571deb8 + d672dff commit 5a3adde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -1362,14 +1362,21 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent*)event
{
body = body? body : [VectorL10n noticeFileAttachment];

NSDictionary *fileInfo = contentToUse[@"info"];
NSDictionary *fileInfo;
MXJSONModelSetDictionary(fileInfo, contentToUse[@"info"]);
if (fileInfo)
{
NSNumber *fileSize = fileInfo[@"size"];
NSNumber *fileSize;
MXJSONModelSetNumber(fileSize, fileInfo[@"size"])
if (fileSize)
{
body = [NSString stringWithFormat:@"%@ (%@)", body, [MXTools fileSizeToString: fileSize.longValue]];
}
else
{
MXLogDebug(@"[MXKEventFormatter] Warning: Unsupported m.file format: %@", event.description);
*error = MXKEventFormatterErrorUnsupported;
}
}
}
else
Expand Down
1 change: 1 addition & 0 deletions changelog.d/7406.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manage bad m.file attachment format.

0 comments on commit 5a3adde

Please sign in to comment.