TF-2510 Validate outside & inline attachment
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -27,4 +27,10 @@ extension AttachmentExtension on Attachment {
|
||||
disposition: disposition ?? this.disposition
|
||||
);
|
||||
}
|
||||
|
||||
bool isOutsideAttachment(List<Attachment> htmlBodyAttachments) {
|
||||
return (isDispositionAttachmentNoCID() || !isDispositionInlined()) &&
|
||||
!isApplicationRTFInlined() &&
|
||||
!htmlBodyAttachments.include(this);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:model/extensions/attachment_extension.dart';
|
||||
|
||||
extension ListAttachmentExtension on List<Attachment> {
|
||||
|
||||
@@ -14,21 +15,18 @@ extension ListAttachmentExtension on List<Attachment> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<Attachment> getListAttachmentsDisplayedOutside(List<Attachment>? htmlBodyAttachments) {
|
||||
return where((attachment) => _validateOutsideAttachment(attachment, htmlBodyAttachments)).toList();
|
||||
List<Attachment> getListAttachmentsDisplayedOutside(List<Attachment> htmlBodyAttachments) {
|
||||
return where((attachment) => attachment.isOutsideAttachment(htmlBodyAttachments)).toList();
|
||||
}
|
||||
|
||||
bool _validateOutsideAttachment(Attachment attachment, List<Attachment>? htmlBodyAttachments) {
|
||||
final result = (attachment.noCid() || !attachment.isInlined()) && (htmlBodyAttachments == null || !htmlBodyAttachments._include(attachment));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool _include(Attachment newAttachment) {
|
||||
bool include(Attachment newAttachment) {
|
||||
final matchedAttachment = firstWhereOrNull((attachment) => attachment.blobId == newAttachment.blobId);
|
||||
return matchedAttachment != null;
|
||||
}
|
||||
|
||||
List<Attachment> get listAttachmentsDisplayedInContent => where((attachment) => attachment.hasCid()).toList();
|
||||
List<Attachment> get listAttachmentsDisplayedInContent =>
|
||||
where((attachment) => attachment.hasCid() && attachment.isDispositionInlined())
|
||||
.toList();
|
||||
|
||||
Map<String, String> toMapCidImageDownloadUrl({
|
||||
required AccountId accountId,
|
||||
|
||||
Reference in New Issue
Block a user