mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 09:53:13 +00:00
Merge pull request #7946 from overleaf/msm-settings-domain-blocklist
[Settings] domain blocklist for email autocompletion GitOrigin-RevId: 62444f0f903ce3feae585c84c9f01164eac42a1f
This commit is contained in:
parent
920a5921c7
commit
8c611a8f49
3 changed files with 82 additions and 0 deletions
|
@ -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])
|
||||
|
|
|
@ -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
|
|
@ -189,6 +189,23 @@ describe('<AddEmailInput/>', 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
|
||||
|
|
Loading…
Reference in a new issue