Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
f5e09bc
(wip) move in the direction of common renderer
Apr 5, 2023
73082cf
fix
Apr 7, 2023
e91bc1b
fix
Apr 8, 2023
928fbbf
(wip) better attachment recognition
Apr 12, 2023
db8e0ba
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 12, 2023
e80fb02
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 12, 2023
38ee474
lint fix
Apr 12, 2023
fad9db3
extended test for #5029 for GmailElementReplacer
Apr 13, 2023
02d31d8
fix signature attachment
Apr 13, 2023
bacb7a3
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 13, 2023
6966668
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 15, 2023
269b55f
Temporarily increase test overall timeout
Apr 16, 2023
2e1101b
fix
Apr 16, 2023
598735d
fix
Apr 17, 2023
557ea8d
inrease execution timeout
Apr 17, 2023
c7a6419
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 17, 2023
71ec76d
Merge branch 'master' into issue-5022-gmail-element-replacer-refactor…
ioanmo226 Apr 18, 2023
e7cd1ed
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 19, 2023
f3313fb
(wip) render-only pgp block iframe
Apr 20, 2023
88f1713
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 20, 2023
719637a
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 21, 2023
c6ffa6d
test fix
Apr 22, 2023
43219bf
fixed relay renderer to await for the destination frame readyToReceiv…
Apr 22, 2023
21d8d18
update test and recipe to check pgp block for correctness
Apr 22, 2023
4f881d9
show signature badge
Apr 22, 2023
ab682c9
fix test recipe
Apr 22, 2023
e202c16
simplify tests
Apr 23, 2023
7d6aa45
fix test
Apr 23, 2023
b8a84f9
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 26, 2023
e0197ab
test fixes
Apr 26, 2023
4ef829e
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Apr 28, 2023
4f44474
encrypted message relay rendering, inner attachments, pubkeys inside …
Apr 28, 2023
b935a6b
fix tests
Apr 29, 2023
b579ea8
test setup for text/plain messages
Apr 30, 2023
8474dda
encryptedMsg from inline blocks, wire render relay to InboxActiveThre…
Apr 30, 2023
bcbe056
fix some tests
Apr 30, 2023
d52d8ce
fix some tests
May 1, 2023
65d1bd4
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 1, 2023
3313c13
wiring needPassphrase
May 1, 2023
9bbdb8e
fixes
May 2, 2023
249b44c
enable print
May 2, 2023
07dff80
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 2, 2023
a602a16
fix
May 2, 2023
52b13ee
goBack works in offline mode
May 3, 2023
eddf070
bogus PGP message
May 3, 2023
bb9be06
setup mock gmail for nested multipart/mixed and chunk download support
May 3, 2023
8af508c
Added OpenPGP_signature webmailNamePattern
May 3, 2023
47c1ff4
more mock gmail tests
May 3, 2023
fa601d4
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 4, 2023
efcfe85
fix tests
May 4, 2023
9742d02
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 5, 2023
3475511
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 7, 2023
0c6639f
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 7, 2023
b5ab531
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 8, 2023
add21f8
refactor to use only pgp_render_block.htm (wip)
May 8, 2023
efc7e78
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 8, 2023
79aec82
cleanup
May 8, 2023
002258b
cleanup
May 8, 2023
7c8872d
temporarily increase execution_time_limit
May 8, 2023
85b7361
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 8, 2023
1afb4e5
fix
May 8, 2023
a75b409
revert debug code
May 9, 2023
a3ed8ae
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 10, 2023
9b92dda
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 10, 2023
734b4b5
signerEmail fix
May 10, 2023
3b55b3f
fix test for #3944
May 11, 2023
7e86b57
fix test for #3944
May 11, 2023
16bcf06
isBodyEmpty fix
May 11, 2023
888dac9
improved mock gmail page
May 11, 2023
f0c13f8
updated test message for lookup
May 11, 2023
ab4d8fb
test fix
May 11, 2023
9f14ac9
fix google mock
May 11, 2023
7ccff98
fix tests using the same message 17dad75e63e47f97
May 11, 2023
f06c9e0
fix test according to sender email
May 11, 2023
5464eb2
changed test file to have 'full' version instead of 'raw'
May 11, 2023
d1e5ee9
simplify test and test gmail mock as well
May 11, 2023
f49f6e6
plain text rendering in inbox
May 12, 2023
ca4494d
test fix
May 12, 2023
354dea8
updated mock to store sent message and extract it in full format
May 12, 2023
3c8af29
base64 decoding in mock tests
May 13, 2023
3bd4a28
base64 decoding in one more test
May 13, 2023
ac5b006
don't allow incomplete blocks where we don't need them
May 13, 2023
13cb677
render download progress initiated by content script
May 14, 2023
118e372
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 15, 2023
401a653
don't enqueue progress updates
May 15, 2023
ac30f6f
reimplemented key mismatch and removed Gmail.extractArmoredBlock
May 15, 2023
adde79a
test fix
May 15, 2023
be0f9b9
MsgBlockParser fix
May 15, 2023
dde4394
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 15, 2023
428c92e
fixed gmail mock
May 15, 2023
c89a7c8
cleanup
May 15, 2023
c92a21e
removed unused BrowserMsg messages
May 15, 2023
28c1039
wire progress to inbox via shortcut callback
May 16, 2023
2e5bf11
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 16, 2023
02ed077
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 16, 2023
57ceb17
offline message decryption fallback
May 17, 2023
2a60a29
added message for testing encrypted MIME without a subject
May 17, 2023
43a6982
more tests restored
May 17, 2023
b250ab7
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 17, 2023
ceca097
temporary test fix
May 17, 2023
861e22c
restored tests with messages
May 19, 2023
ae01624
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 19, 2023
2ce040d
update test
May 19, 2023
fe3a3d0
temporarily increase test timeout
May 19, 2023
36af973
refactor threadHasPgpBlock and processed message
May 19, 2023
ba6b7c5
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 19, 2023
d1c75b0
'SEE ORIGINAL' functionality
May 20, 2023
85b37b5
deleted code related to successfully_received_at_leat_one_message flag
May 20, 2023
e319f30
minimize pgp_pubkey when outgoing message -- fixed and tested
May 22, 2023
a829022
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 22, 2023
9019080
check origin of message
May 22, 2023
bf0e7fb
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 22, 2023
0fd3507
fix: escaped strings for RegExp
May 22, 2023
54e1ff5
renamed to pgp_rendered_block to pgp_block
May 22, 2023
2455734
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 24, 2023
92b78a3
removed todos, simplified code
May 24, 2023
b58d12e
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 24, 2023
4b20e14
fixed from -> email conversion
May 25, 2023
5f18b44
fixed senderEmail parsing
May 25, 2023
fdbec5f
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 25, 2023
598caab
mock fix: escape from address
May 25, 2023
6f131da
simplification
May 25, 2023
ded6b1e
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 25, 2023
1bb60e2
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 25, 2023
5631a0e
tidy up
May 25, 2023
31026a7
converted Dict to Map to avoid potential vulnerabilities
May 25, 2023
6144c13
fix
May 25, 2023
7e0b991
origin control for messages
May 26, 2023
c24c6b3
patches for Firefox
May 26, 2023
f110c22
simplified sendAs-related code, fixed vulnerability
May 27, 2023
50ef01c
simplify initialization, less loads
May 27, 2023
f0c4fe8
clearer code with regard to signedMsg, and a unit test for unusual si…
May 27, 2023
96b7097
test fix
May 27, 2023
88560a6
nicer mock attachment UI
May 28, 2023
19985de
fixed comment
May 28, 2023
bb58fc2
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 28, 2023
4247406
failure to fetch raw signed message will result in attachment status …
May 29, 2023
0249c4f
made method getFileParts private
May 29, 2023
953d325
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 29, 2023
f3011fa
code cleanup
May 29, 2023
9e311c5
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
May 30, 2023
7e447af
simplifications, resource release related to relay manager and passph…
May 30, 2023
4afd8f8
fix: file encoding
ioanmo226 May 31, 2023
400ea61
removed test interference
May 31, 2023
d385f3f
simplification / fetching only missing attachments
May 31, 2023
ee34da1
better gmail mock rendering
Jun 1, 2023
c3d6127
fix
Jun 1, 2023
113a3bf
fixed and tested backup message rendering
Jun 1, 2023
db61dbd
send messages from content script to pgp_block using chrome.runtime
Jun 2, 2023
95887f0
race condition fix
Jun 2, 2023
a209771
cleanup
Jun 2, 2023
e65fa55
cache expiration for downloaded messages
Jun 2, 2023
99b9fda
use Map in ExpirationCache, delete expired chunks
Jun 2, 2023
967fd3d
more patches for Firefox Uint8Array issue
Jun 2, 2023
1a612e7
cleaner code
Jun 3, 2023
94d9e03
XssSafeFactory cleanup
Jun 3, 2023
5f126af
added signature test for gmail mock
Jun 3, 2023
0653a91
retry verification when pubkeys fetch resulted in network error: offl…
Jun 4, 2023
cfa0b32
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 4, 2023
7fa9e1c
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 4, 2023
2794fb4
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 5, 2023
9bc7ed1
OR short-circuit fix
Jun 5, 2023
1137d17
tidying up, comments
Jun 5, 2023
8b0f4ef
more tests
Jun 6, 2023
4cb74a4
comment
Jun 6, 2023
98dcad6
comments and refactoring
Jun 6, 2023
66eaa75
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 7, 2023
7c59e2d
removed failed chunk download from cache
Jun 7, 2023
a61c15d
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 9, 2023
9839b5a
narrow type
Jun 9, 2023
e83698e
regex fix
Jun 9, 2023
fa7189c
refactor public key attachment identification
Jun 9, 2023
0074fbd
added tests for incorrect 'publicKey'-looking attachments
Jun 10, 2023
71ccd08
removed rejected promises from cache, simplification
Jun 10, 2023
96c82e3
remove rejected promises from cache: fix, unit test
Jun 11, 2023
808e1e7
comment
Jun 11, 2023
24f6766
simplify and comment
Jun 11, 2023
1c13f25
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
rrrooommmaaa Jun 13, 2023
d0e78cd
checked todo
rrrooommmaaa Jun 13, 2023
39d6dfb
'auth needed' notification is shown when processing armored blocks - …
rrrooommmaaa Jun 14, 2023
7fa5b5f
'auth needed' notification is shown when processing armored blocks - fix
rrrooommmaaa Jun 14, 2023
13b23ba
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
rrrooommmaaa Jun 14, 2023
a59bcbe
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
rrrooommmaaa Jun 16, 2023
2e7559b
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 16, 2023
5b389f5
tidy up, exception handling, removed unused FormatError
Jun 16, 2023
267cabc
renaming and tidying up
Jun 17, 2023
3af3fe3
tidy up
Jun 17, 2023
42f108b
XSS safety review, comments
Jun 18, 2023
f646341
extra XSS escapes
Jun 18, 2023
cd22928
plainSubject logic restored (no unit tests), comments
Jun 18, 2023
319e4eb
plainSubject logic restored additional updates (no unit tests)
Jun 18, 2023
f408857
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
Jun 19, 2023
a7a5407
simplified test
Jun 19, 2023
ee4ff6e
Merge branch 'master' into issue-5022-gmail-element-replacer-refactor…
rrrooommmaaa Jun 19, 2023
c10350c
Merge branch 'master' into issue-5022-gmail-element-replacer-refactor…
rrrooommmaaa Jun 19, 2023
8797e02
Merge branch 'master' into issue-5022-gmail-element-replacer-refactor…
rrrooommmaaa Jun 19, 2023
1d98bc2
fix script
Jun 19, 2023
4a2fc81
lazy matching
Jun 19, 2023
63fd738
Merge branch 'master' into issue-5022-gmail-element-replacer-refactor…
rrrooommmaaa Jun 19, 2023
f036a00
Merge remote-tracking branch 'origin/master' into issue-5022-gmail-el…
rrrooommmaaa Jun 19, 2023
78613f9
fix build script on macOS
sosnovsky Jun 20, 2023
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
2 changes: 1 addition & 1 deletion .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ blocks:
- name: Mock UI Tests
dependencies: []
execution_time_limit:
minutes: 30
minutes: 45
task:
secrets:
- name: flowcrypt-browser-ci-secrets
Expand Down
15 changes: 0 additions & 15 deletions extension/chrome/dev/ci_pgp_host_page.htm

This file was deleted.

21 changes: 0 additions & 21 deletions extension/chrome/dev/ci_pgp_host_page.ts

This file was deleted.

4 changes: 2 additions & 2 deletions extension/chrome/dev/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Catch.try(async () => {
const fetchableAttachments: Attachment[] = [];
const skippedAttachments: Attachment[] = [];
for (const msg of messages) {
for (const attachment of GmailParser.findAttachments(msg)) {
for (const attachment of GmailParser.findAttachments(msg, msg.id)) {
if (attachment.length > 1024 * 1024 * 7) {
// over 7 mb - attachment too big
skippedAttachments.push(
Expand All @@ -102,7 +102,7 @@ Catch.try(async () => {
}
}
}
await gmail.fetchAttachments(fetchableAttachments, percent => print(`Percent attachments done: ${percent}`));
await gmail.fetchAttachmentsMissingData(fetchableAttachments, percent => print(`Percent attachments done: ${percent}`));
const attachments: { [id: string]: { data: string; size: number } } = {};
for (const attachment of fetchableAttachments.concat(skippedAttachments)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
29 changes: 16 additions & 13 deletions extension/chrome/elements/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PromiseCancellation, Str, Url } from '../../js/common/core/common.js';
import { Api } from '../../js/common/api/shared/api.js';
import { ApiErr } from '../../js/common/api/shared/api-error.js';
import { Assert } from '../../js/common/assert.js';
import { Attachment } from '../../js/common/core/attachment.js';
import { Attachment, AttachmentId } from '../../js/common/core/attachment.js';
import { Browser } from '../../js/common/browser/browser.js';
import { Catch } from '../../js/common/platform/catch.js';
import { Gmail } from '../../js/common/api/email-provider/gmail/gmail.js';
Expand All @@ -32,10 +32,8 @@ export class AttachmentDownloadView extends View {
protected readonly isEncrypted: boolean;
protected readonly errorDetailsOpened: boolean;
protected readonly type: string | undefined;
protected readonly msgId: string | undefined;
protected readonly id: string | undefined;
protected readonly name: string | undefined;
protected readonly url: string | undefined;
protected readonly attachmentId: AttachmentId;
protected readonly gmail: Gmail;
protected attachment!: Attachment;
protected ppChangedPromiseCancellation: PromiseCancellation = { cancel: false };
Expand Down Expand Up @@ -73,11 +71,17 @@ export class AttachmentDownloadView extends View {
this.errorDetailsOpened = uncheckedUrlParams.errorDetailsOpened === true;
this.size = uncheckedUrlParams.size ? parseInt(String(uncheckedUrlParams.size)) : undefined;
this.type = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'type');
this.msgId = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'msgId');
this.id = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'attachmentId');
this.name = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'name');
// url contains either actual url of remote content or objectUrl for direct content, either way needs to be downloaded
this.url = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'url');
const url = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'url');
if (url) {
this.attachmentId = { url };
} else {
this.attachmentId = {
msgId: Assert.urlParamRequire.string(uncheckedUrlParams, 'msgId'),
id: Assert.urlParamRequire.string(uncheckedUrlParams, 'attachmentId'),
};
}
this.gmail = new Gmail(this.acctEmail);
}

Expand All @@ -91,11 +95,9 @@ export class AttachmentDownloadView extends View {
this.fesUrl = storage.fesUrl;
try {
this.attachment = new Attachment({
...this.attachmentId,
name: this.origNameBasedOnFilename,
type: this.type,
msgId: this.msgId,
id: this.id,
url: this.url,
});
} catch (e) {
Catch.reportErr(e);
Expand All @@ -107,9 +109,9 @@ export class AttachmentDownloadView extends View {
this.renderHeader();
$('#name').attr('title', this.name || '');
$('img#file-format').attr('src', this.getFileIconSrc());
if (!this.size && this.url) {
if (!this.size && 'url' in this.attachmentId) {
// download url of a file that has an unknown size
this.getUrlFileSize(this.url)
this.getUrlFileSize(this.attachmentId.url)
.then(fileSize => {
if (typeof fileSize !== 'undefined') {
this.size = fileSize;
Expand Down Expand Up @@ -162,7 +164,7 @@ export class AttachmentDownloadView extends View {
this.attachment.setData(await Api.download(this.attachment.url, this.renderProgress));
} else if (this.attachment.id && this.attachment.msgId) {
// gmail attId
const { data } = await this.gmail.attachmentGet(this.attachment.msgId, this.attachment.id, this.renderProgress);
const { data } = await this.gmail.attachmentGet(this.attachment.msgId, this.attachment.id, { download: this.renderProgress });
this.attachment.setData(data);
} else {
throw new Error('File is missing both id and url - this should be fixed');
Expand Down Expand Up @@ -246,6 +248,7 @@ export class AttachmentDownloadView extends View {

private processAsPublicKeyAndHideAttachmentIfAppropriate = async () => {
// todo: we should call this detection in the main `core/Attachment.treatAs` (e.g. in the context of GmailElementReplacer and InboxActiveThreadModule)
// and we'll also be able to minimize the pgp_pubkey block if isOutgoing
// should be possible after #4906 is done
if (((this.attachment.msgId && this.attachment.id) || this.attachment.url) && this.attachment.isPublicKey()) {
// this is encrypted public key - download && decrypt & parse & render
Expand Down
4 changes: 1 addition & 3 deletions extension/chrome/elements/attachment_preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ View.run(
try {
Xss.sanitizeRender(this.attachmentPreviewContainer, `${Ui.spinner('green', 'large_spinner')}<span class="download_progress"></span>`);
this.attachment = new Attachment({
...this.attachmentId,
name: this.origNameBasedOnFilename,
type: this.type,
msgId: this.msgId,
id: this.id,
url: this.url,
});
await this.downloadDataIfNeeded();
const result = this.isEncrypted ? await this.decrypt() : this.attachment.getData();
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/elements/backup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</div>
<div class="line fingerprints hide_if_compact">Key Fingerprint: <span class="fingerprint good"></span></div>
<div class="line">
<span class="private_key_status"></span>
<span class="private_key_status" data-test="private-key-status"></span>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Ui } from '../../../js/common/browser/ui.js';
import { Buf } from '../../../js/common/core/buf.js';
import { Str, Url } from '../../../js/common/core/common.js';
import { DecryptErrTypes, MsgUtil } from '../../../js/common/core/crypto/pgp/msg-util.js';
import { Mime, MimeContent, MimeProccesedMsg } from '../../../js/common/core/mime.js';
import { Mime, MimeContentWithHeaders, MimeProccesedMsg } from '../../../js/common/core/mime.js';
import { MsgBlockParser } from '../../../js/common/core/msg-block-parser.js';
import { Catch } from '../../../js/common/platform/catch.js';
import { GlobalStore } from '../../../js/common/platform/store/global-store.js';
Expand Down Expand Up @@ -298,7 +298,7 @@ export class ComposeDraftModule extends ViewModule<ComposeView> {
}
};

private fillAndRenderDraftHeaders = async (decoded: MimeContent) => {
private fillAndRenderDraftHeaders = async (decoded: MimeContentWithHeaders) => {
this.view.recipientsModule.addRecipientsAndShowPreview({ to: decoded.to, cc: decoded.cc, bcc: decoded.bcc });
if (decoded.from) {
this.view.S.now('input_from').val(decoded.from);
Expand Down
52 changes: 26 additions & 26 deletions extension/chrome/elements/compose-modules/compose-quote-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';

import { Bm, BrowserMsg } from '../../../js/common/browser/browser-msg.js';
import { FormatError, MsgUtil, DecryptErrTypes } from '../../../js/common/core/crypto/pgp/msg-util.js';
import { MsgUtil, DecryptErrTypes } from '../../../js/common/core/crypto/pgp/msg-util.js';
import { ApiErr } from '../../../js/common/api/shared/api-error.js';
import { Buf } from '../../../js/common/core/buf.js';
import { Catch } from '../../../js/common/platform/catch.js';
Expand Down Expand Up @@ -123,29 +123,31 @@ export class ComposeQuoteModule extends ViewModule<ComposeView> {
decryptedAndFormatedContent.push(Xss.htmlUnescape(htmlParsed));
} else if (block.type === 'plainHtml') {
decryptedAndFormatedContent.push(Xss.htmlUnescape(Xss.htmlSanitizeAndStripAllTags(stringContent, '\n', false)));
} else if (['encryptedAttachment', 'decryptedAttachment', 'plainAttachment'].includes(block.type)) {
if (block.attachmentMeta?.data) {
let attachmentMeta: { content: Buf; filename?: string } | undefined;
if (block.type === 'encryptedAttachment') {
this.setQuoteLoaderProgress('decrypting...');
const result = await MsgUtil.decryptMessage({
kisWithPp: await KeyStore.getAllWithOptionalPassPhrase(this.view.acctEmail),
encryptedData: block.attachmentMeta.data,
verificationPubs: [], // todo: #4158 signature verification of attachments
});
if (result.success) {
attachmentMeta = { content: result.content, filename: result.filename };
}
} else {
attachmentMeta = {
content: Buf.fromUint8(block.attachmentMeta.data),
filename: block.attachmentMeta.name,
};
}
if (attachmentMeta) {
const file = new File([attachmentMeta.content], attachmentMeta.filename || '');
decryptedFiles.push(file);
} else if (
block.attachmentMeta &&
'data' in block.attachmentMeta &&
['encryptedAttachment', 'decryptedAttachment', 'plainAttachment'].includes(block.type)
) {
let attachmentMeta: { content: Buf; filename?: string } | undefined;
if (block.type === 'encryptedAttachment') {
this.setQuoteLoaderProgress('decrypting...');
const result = await MsgUtil.decryptMessage({
kisWithPp: await KeyStore.getAllWithOptionalPassPhrase(this.view.acctEmail),
encryptedData: block.attachmentMeta.data,
verificationPubs: [], // todo: #4158 signature verification of attachments
});
if (result.success) {
attachmentMeta = { content: result.content, filename: result.filename };
}
} else {
attachmentMeta = {
content: Buf.fromUint8(block.attachmentMeta.data),
filename: block.attachmentMeta.name,
};
}
if (attachmentMeta) {
const file = new File([attachmentMeta.content], attachmentMeta.filename || '');
decryptedFiles.push(file);
}
} else {
decryptedAndFormatedContent.push(stringContent);
Expand All @@ -158,9 +160,7 @@ export class ComposeQuoteModule extends ViewModule<ComposeView> {
decryptedFiles,
};
} catch (e) {
if (e instanceof FormatError) {
Xss.sanitizeAppend(this.view.S.cached('input_text'), `<br/>\n<br/>\n<br/>\n${Xss.escape(e.data)}`);
} else if (ApiErr.isNetErr(e)) {
if (ApiErr.isNetErr(e)) {
// todo: retry
} else if (ApiErr.isAuthErr(e)) {
BrowserMsg.send.notificationShowAuthPopupNeeded(this.view.parentTabId, { acctEmail: this.view.acctEmail });
Expand Down
8 changes: 0 additions & 8 deletions extension/chrome/elements/pgp_block.htm
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
<script src="/lib/linkify.min.js"></script>
<script src="/lib/linkify-html.min.js"></script>
<script src="/lib/filesize.js"></script>
<script src="/lib/iso-8859-2.js"></script>
<script src="/lib/emailjs/punycode.js"></script>
<script src="/lib/emailjs/emailjs-stringencoding.js"></script>
<script src="/lib/emailjs/emailjs-mime-codec.js"></script>
<script src="/lib/emailjs/emailjs-mime-types.js"></script>
<script src="/lib/emailjs/emailjs-addressparser.js"></script>
<script src="/lib/emailjs/emailjs-mime-builder.js"></script>
<script src="/lib/emailjs/emailjs-mime-parser.js"></script>
<script src="pgp_block.js" type="module"></script>
</body>
</html>
Loading