Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d23ff7f6 authored by cketti's avatar cketti
Browse files

Only hide inline image parts with Content-Id header

The assumption is those parts are images referenced by the main HTML
part. Even without "attachment box" the user is able to save them using
a long-press in the WebView.
parent d6967230
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import android.content.Context;
import android.net.Uri;
@@ -131,12 +132,12 @@ public class AttachmentInfoExtractor {
            name = "noname" + ((extension != null) ? "." + extension : "");
        }

        // Inline parts with a content-id are almost certainly components of an HTML message
        // not attachments. Only show them if the user pressed the button to show more
        // attachments.
        // Inline parts with a Content-Id header and a MIME type of image/* are probably components of an HTML message,
        // not attachments.
        if (contentDisposition != null &&
                MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)") &&
                part.getHeader(MimeHeader.HEADER_CONTENT_ID).length > 0) {
                part.getHeader(MimeHeader.HEADER_CONTENT_ID).length > 0 &&
                mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("image/")) {
            inlineAttachment = true;
        }