diff --git a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx index 5eeab6af01..3e1805ebe0 100644 --- a/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx +++ b/services/web/frontend/js/features/settings/components/emails/add-email/input.tsx @@ -8,6 +8,7 @@ import { } from 'react' import { getJSON } from '../../../../../infrastructure/fetch-json' import useAbortController from '../../../../../shared/hooks/use-abort-controller' +import domainBlocklist from '../../../domain-blocklist' const LOCAL_AND_DOMAIN_REGEX = /([^@]+)@(.+)/ @@ -91,6 +92,9 @@ function Input({ onChange }: InputProps) { if (!(data && data[0])) { return } + if (domainBlocklist.has(data[0].hostname)) { + return + } const hostname = data[0]?.hostname if (hostname) { domainCache.set(match.domain, data[0]) diff --git a/services/web/frontend/js/features/settings/domain-blocklist.ts b/services/web/frontend/js/features/settings/domain-blocklist.ts new file mode 100644 index 0000000000..fa7b2e0fbe --- /dev/null +++ b/services/web/frontend/js/features/settings/domain-blocklist.ts @@ -0,0 +1,61 @@ +const domainBlocklist = new Set(['overleaf.com']) +const commonTLDs = [ + 'br', + 'cn', + 'co', + 'co.jp', + 'co.uk', + 'com', + 'com.au', + 'de', + 'fr', + 'in', + 'info', + 'io', + 'net', + 'no', + 'ru', + 'se', + 'us', + 'com.tw', + 'com.br', + 'pl', + 'it', + 'co.in', + 'com.mx', +] as const +const commonDomains = [ + 'gmail', + 'googlemail', + 'icloud', + 'me', + 'yahoo', + 'ymail', + 'yahoomail', + 'hotmail', + 'live', + 'msn', + 'outlook', + 'gmx', + 'mail', + 'aol', + '163', + 'mac', + 'qq', + 'o2', + 'libero', + '126', + 'protonmail', + 'yandex', + 'yeah', + 'web', + 'foxmail', +] as const + +for (const domain of commonDomains) { + for (const tld of commonTLDs) { + domainBlocklist.add(`${domain}.${tld}`) + } +} + +export default domainBlocklist diff --git a/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx b/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx index b6515e3251..22a7820518 100644 --- a/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx +++ b/services/web/test/frontend/features/settings/components/emails/add-email-input.test.tsx @@ -189,6 +189,23 @@ describe('', function () { }) }) + describe('when there is a match for a blocklisted domain', function () { + beforeEach(function () { + const blockedInstitution = [ + { university: { id: 1 }, hostname: 'overleaf.com' }, + ] + fetchMock.get('express:/institutions/domains', blockedInstitution) + fireEvent.change(screen.getByRole('textbox'), { + target: { value: 'user@o' }, + }) + }) + + it('should not render the suggestion', async function () { + await fetchMock.flush(true) + expect(screen.queryByText('user@overleaf.com')).to.be.null + }) + }) + describe('while waiting for a response', function () { beforeEach(async function () { // type an initial suggestion