Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d708e73
add Xss.stripEmojis()
martgil Jul 23, 2023
063cae6
add test
martgil Jul 23, 2023
703fde4
Merge branch 'master' into issue-5308-fix-email-sending-issue-for-rec…
martgil Jul 24, 2023
73f31bf
Merge branch 'master' into issue-5308-fix-email-sending-issue-for-rec…
martgil Jul 29, 2023
83eb2ee
update compose.ts
martgil Jul 29, 2023
38715e1
Merge branch 'master' into issue-5308-fix-email-sending-issue-for-rec…
martgil Jul 31, 2023
271aca3
store recipient info to recipientObj
martgil Jul 31, 2023
b3306c6
add emojiRegex lib
martgil Jul 31, 2023
04f8de1
update reference
martgil Jul 31, 2023
140bfc1
github ci test
martgil Aug 2, 2023
4157117
remove github ci test
martgil Aug 2, 2023
c987f0c
add webpack configuration emoji-regex
martgil Aug 2, 2023
74b1caf
Merge remote-tracking branch 'origin/master' into issue-5308-fix-emai…
martgil Sep 27, 2023
f06e358
remove emoji-regex package
martgil Sep 27, 2023
fa17ce5
add Intl.Segmenter polyfill
martgil Sep 27, 2023
6a21f97
remove Intl.Segmenter polyfill
martgil Sep 27, 2023
10fe721
revert changes on build.sh
martgil Sep 27, 2023
a4f456e
pr reviews: code simplification
martgil Sep 29, 2023
690e234
Merge branch 'master' into issue-5308-fix-email-sending-issue-for-rec…
martgil Sep 30, 2023
75250df
pr reviews: better test checking
martgil Sep 30, 2023
0d7fec5
Merge remote-tracking branch 'origin/master' into issue-5308-fix-emai…
martgil Oct 2, 2023
c600479
pr reviews: code and test simplification
martgil Oct 2, 2023
35bd5fe
pr reviews: revert other changes
martgil Oct 2, 2023
40106cf
revert unrelated change
martgil Oct 3, 2023
31106ad
cleanup
martgil Oct 3, 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
5 changes: 4 additions & 1 deletion extension/css/cryptup.css
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,10 @@ body#new_message.full_window {
}

body#new_message.full_window table#compose {
box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
box-shadow:
0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12),
0 5px 5px -3px rgba(0, 0, 0, 0.2);
}

div#reply_message_table_container {
Expand Down
7 changes: 4 additions & 3 deletions extension/js/common/api/account-servers/external-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ClientConfigurationError, ClientConfigurationJson } from '../../client-
import { InMemoryStore } from '../../platform/store/in-memory-store.js';
import { GoogleOAuth } from '../authentication/google/google-oauth.js';
import { AuthenticationConfiguration } from '../../authentication-configuration.js';
import { Xss } from '../../platform/xss.js';

// todo - decide which tags to use
type EventTag = 'compose' | 'decrypt' | 'setup' | 'settings' | 'import-pub' | 'import-prv';
Expand Down Expand Up @@ -143,9 +144,9 @@ export class ExternalService extends Api {
JSON.stringify({
associateReplyToken,
from,
to: (recipients.to || []).map(Str.formatEmailWithOptionalName),
cc: (recipients.cc || []).map(Str.formatEmailWithOptionalName),
bcc: (recipients.bcc || []).map(Str.formatEmailWithOptionalName),
to: (recipients.to || []).map(Str.formatEmailWithOptionalName).map(Xss.stripEmojis),
cc: (recipients.cc || []).map(Str.formatEmailWithOptionalName).map(Xss.stripEmojis),
bcc: (recipients.bcc || []).map(Str.formatEmailWithOptionalName).map(Xss.stripEmojis),
})
),
});
Expand Down
6 changes: 5 additions & 1 deletion extension/js/common/platform/xss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as DOMPurify from 'dompurify';
import { checkValidURL, CID_PATTERN, Str } from '../core/common.js';

export type SanitizeImgHandling = 'IMG-DEL' | 'IMG-KEEP' | 'IMG-TO-PLAIN-TEXT';

/**
* This class is in platform/ folder because most of it depends on platform specific code
* - in browser the implementation uses DOMPurify
Expand Down Expand Up @@ -51,6 +50,7 @@ export class Xss {
private static FORBID_ATTR = ['background'];
private static HREF_REGEX_CACHE: RegExp | undefined;
private static FORBID_CSS_STYLE = /z-index:[^;]+;|position:[^;]+;|background[^;]+;/g;
private static EMOJI_REGEX = /(?![*#0-9]+)[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]/gu;

public static sanitizeRender = (selector: string | HTMLElement | JQuery<HTMLElement>, dirtyHtml: string) => {
// browser-only (not on node)
Expand Down Expand Up @@ -230,6 +230,10 @@ export class Xss {
return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\//g, '&#x2F;');
};

public static stripEmojis = (str: string) => {
return str.replace(Xss.EMOJI_REGEX, '');
};

public static htmlUnescape = (str: string) => {
// the &nbsp; at the end is replaced with an actual NBSP character, not a space character. IDE won't show you the difference. Do not change.
return str
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/source/mock/fes/shared-tenant-fes-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export const getMockSharedTenantFesEndpoints = (config: FesConfig | undefined):
if (req.method === 'POST' && typeof body === 'string') {
expect(body).to.contain('-----BEGIN PGP MESSAGE-----');
expect(body).to.contain('"associateReplyToken":"mock-fes-reply-token"');
if (body.includes('NameWithEmoji')) {
expect(body).to.not.include('⭐');
}
const response = {
// this url is required for pubkey encrypted message
url: `https://flowcrypt.com/shared-tenant-fes/message/6da5ea3c-d2d6-4714-b15e-f29c805e5c6a`,
Expand Down
18 changes: 18 additions & 0 deletions test/source/tests/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te
})
);

test(
'compose - strip emojis in a recipient email address',
testWithBrowser(async (t, browser) => {
const acct = 'flowcrypt.compatibility@gmail.com';
await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility', {
google: { acctAliases: flowcryptCompatibilityAliasList },
});
const recipientEmail = 'NameWithEmoji ⭐ Test <test@email.com>';
const msgPwd = 'super hard password for the message';
const subject = 'Test Sending Message With Recipient Name Contains Emoji';
const composePage = await ComposePageRecipe.openStandalone(t, browser, 'compatibility');
await ComposePageRecipe.selectFromOption(composePage, acct);
await ComposePageRecipe.fillMsg(composePage, { to: recipientEmail }, subject);
await ComposePageRecipe.sendAndClose(composePage, { password: msgPwd });
// The actualt test for this is present in '/shared-tenant-fes/api/v1/message' of shared-tenant-fes mock endpoint.
})
);

test(
'compose - check for sender [flowcrypt.compatibility@gmail.com] from a password-protected email',
testWithBrowser(async (t, browser) => {
Expand Down