Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ViewModule } from '../../../js/common/view-module.js';
import { ComposeView } from '../compose.js';
import { AjaxErrMsgs } from '../../../js/common/api/shared/api-error.js';

class ComposerUserError extends Error { }
export class ComposerUserError extends Error { }
class ComposerNotReadyError extends ComposerUserError { }
export class ComposerResetBtnTrigger extends Error { }

Expand Down Expand Up @@ -83,7 +83,7 @@ export class ComposeErrModule extends ViewModule<ComposeView> {
}
}
} else if (e instanceof ComposerUserError) {
await Ui.modal.error(e.message);
await Ui.modal.error(e.message, true);
} else {
if (!(e instanceof ComposerResetBtnTrigger || e instanceof ComposerNotReadyError)) {
Catch.reportErr(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Attachment } from '../../../js/common/core/attachment.js';
import { BrowserMsg } from '../../../js/common/browser/browser-msg.js';
import { Buf } from '../../../js/common/core/buf.js';
import { Catch } from '../../../js/common/platform/catch.js';
import { ComposerUserError } from './compose-err-module.js';
import { ComposeSendBtnPopoverModule } from './compose-send-btn-popover-module.js';
import { GeneralMailFormatter } from './formatters/general-mail-formatter.js';
import { GmailRes } from '../../../js/common/api/email-provider/gmail/gmail-parser.js';
Expand Down Expand Up @@ -164,15 +165,24 @@ export class ComposeSendBtnModule extends ViewModule<ComposeView> {
const img: Element = node;
const src = img.getAttribute('src') as string;
const { mimeType, data } = this.parseInlineImageSrc(src);
const imgAttachment = new Attachment({
cid: Attachment.attachmentId(),
name: img.getAttribute('name') || '',
type: mimeType,
data: Buf.fromBase64Str(data),
inline: true
});
img.setAttribute('src', `cid:${imgAttachment.cid}`);
imgAttachments.push(imgAttachment);
if (mimeType && data) {
const imgAttachment = new Attachment({
cid: Attachment.attachmentId(),
name: img.getAttribute('name') || '',
type: mimeType,
data: Buf.fromBase64Str(data),
inline: true
});
img.setAttribute('src', `cid:${imgAttachment.cid}`);
imgAttachments.push(imgAttachment);
} else {
throw new ComposerUserError(`
Unable to parse an inline image <details>
<summary>See error details</summary>
src="${Xss.escape(src)}"
</details>
`);
}
}
});
const htmlWithCidImages = DOMPurify.sanitize(html);
Expand Down