-
Notifications
You must be signed in to change notification settings - Fork 52
Extract inline images into attachments for plain rich text messages #3256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
da92e8b
Extract inline images into attachments for plain rich text messages
fb314cb
Move extractInlineImagesToAttachments() method from PlainMsgMailForma…
a8534c6
clean up
2a505ec
use MimeNode.getHeader()
2dd1e0b
fix displayImageSrcLinkAsImg(), do not show <img src="cid:..." as (re…
f68b85f
extract inline images only when sending plain rich-text messages
f896c36
revert unnecessary addition
6e3bdbd
get rid of the expensive regex
247521b
add test
01790f6
take parsedMail.html into consideration in storeSentMessage
e0176f8
improve if
501193d
move extractInlineImagesToAttachments() to ComposeSendBtnModule
7fcaae4
finalyze, keepCidLinks: true
ba058b8
better naming: htmlWithInlineImages -> htmlWithCidImages
a85da67
fix the 'send pwd encrypted msg & check on flowcrypt site' test
d491c8f
slight style update
5008408
added a todo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -705,14 +705,18 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te | |
| expect(await composePage.readHtml('@input-body')).to.include('<div dir="rtl">مرحبا<br></div>'); | ||
| })); | ||
|
|
||
| ava.default('compose - sending and rendering encrypted message with image ', testWithBrowser('compatibility', async (t, browser) => { | ||
| ava.default('compose - sending and rendering encrypted message with image', testWithBrowser('compatibility', async (t, browser) => { | ||
| await sendImgAndVerifyPresentInSentMsg(t, browser, 'encrypt'); | ||
| })); | ||
|
|
||
| ava.default('compose - sending and rendering signed message with image ', testWithBrowser('compatibility', async (t, browser) => { | ||
| ava.default('compose - sending and rendering signed message with image', testWithBrowser('compatibility', async (t, browser) => { | ||
| await sendImgAndVerifyPresentInSentMsg(t, browser, 'sign'); | ||
| })); | ||
|
|
||
| ava.default('compose - sending and rendering plain message with image', testWithBrowser('compatibility', async (t, browser) => { | ||
| await sendImgAndVerifyPresentInSentMsg(t, browser, 'plain'); | ||
| })); | ||
|
|
||
| ava.default('compose - sending and rendering message with U+10000 code points', testWithBrowser('compatibility', async (t, browser) => { | ||
| const rainbow = '\ud83c\udf08'; | ||
| await sendTextAndVerifyPresentInSentMsg(t, browser, rainbow, { sign: true, encrypt: false }); | ||
|
|
@@ -1030,10 +1034,11 @@ const pastePublicKeyManually = async (composeFrame: ControllableFrame, inboxPage | |
| await inboxPage.waitTillGone('@dialog-add-pubkey'); | ||
| }; | ||
|
|
||
| const sendImgAndVerifyPresentInSentMsg = async (t: AvaContext, browser: BrowserHandle, sendingType: 'encrypt' | 'sign') => { | ||
| const sendImgAndVerifyPresentInSentMsg = async (t: AvaContext, browser: BrowserHandle, sendingType: 'encrypt' | 'sign' | 'plain') => { | ||
| // send a message with image in it | ||
| const imgBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAnElEQVR42u3RAQ0AAAgDIE1u9FvDOahAVzLFGS1ECEKEIEQIQoQgRIgQIQgRghAhCBGCECEIQYgQhAhBiBCECEEIQoQgRAhChCBECEIQIgQhQhAiBCFCEIIQIQgRghAhCBGCEIQIQYgQhAhBiBCEIEQIQoQgRAhChCAEIUIQIgQhQhAiBCEIEYIQIQgRghAhCBEiRAhChCBECEK+W3uw+TnWoJc/AAAAAElFTkSuQmCC'; | ||
| const subject = `Test Sending ${sendingType === 'sign' ? 'Signed' : 'Encrypted'} Message With Image ${Util.lousyRandom()}`; | ||
| const sendingTypeForHumans = sendingType === 'encrypt' ? 'Encrypted' : (sendingType === 'sign' ? 'Signed' : 'Plain'); | ||
| const subject = `Test Sending ${sendingTypeForHumans} Message With Image ${Util.lousyRandom()}`; | ||
| const composePage = await ComposePageRecipe.openStandalone(t, browser, 'compatibility'); | ||
| await ComposePageRecipe.fillMsg(composePage, { to: 'human@flowcrypt.com' }, subject, { richtext: true, sign: sendingType === 'sign', encrypt: sendingType === 'encrypt' }); | ||
| // the following is a temporary hack - currently not able to directly paste an image with puppeteer | ||
|
|
@@ -1042,6 +1047,12 @@ const sendImgAndVerifyPresentInSentMsg = async (t: AvaContext, browser: BrowserH | |
| await ComposePageRecipe.sendAndClose(composePage); | ||
| // get sent msg id from mock | ||
| const sentMsg = new GoogleData('flowcrypt.compatibility@gmail.com').getMessageBySubject(subject)!; | ||
| if (sendingType === 'plain') { | ||
| expect(sentMsg.payload?.body?.data).to.match(/<img src="cid:(.+)@flowcrypt">This is an automated puppeteer test: Test Sending Plain Message With Image/); | ||
| return; | ||
| // todo - this test case is a stop-gap. We need to implement rendering of such messages below, | ||
| // then let test plain messages with images in them (referenced by cid) just like other types of messages below | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make an issue for this |
||
| } | ||
| let url = `chrome/dev/ci_pgp_host_page.htm?frameId=none&msgId=${encodeURIComponent(sentMsg.id)}&senderEmail=flowcrypt.compatibility%40gmail.com&isOutgoing=___cu_false___&acctEmail=flowcrypt.compatibility%40gmail.com`; | ||
| if (sendingType === 'sign') { | ||
| url += '&signature=___cu_true___'; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also todo here for later