Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions src/components/AccountForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
required
type="email"
@change="clearFeedback" />
<p v-if="!isValidEmail(emailAddress)" class="account-form--error">
<p v-if="!validEmail(emailAddress)" class="account-form--error">
{{ t('mail', 'Please enter an email of the format name@example.com') }}
</p>
<NcPasswordField
Expand Down Expand Up @@ -61,7 +61,7 @@
:disabled="loading"
required
@change="clearFeedback" />
<p v-if="!isValidEmail(emailAddress)" class="account-form--error">
<p v-if="!validEmail(emailAddress)" class="account-form--error">
{{ t('mail', 'Please enter an email of the format name@example.com') }}
</p>

Expand Down Expand Up @@ -147,7 +147,7 @@
<h4>{{ t('mail', 'SMTP Settings') }}</h4>
<NcInputField
id="man-smtp-host"
ref="smtpHost"

Check warning on line 150 in src/components/AccountForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'smtpHost' is defined as ref, but never used
v-model="manualConfig.smtpHost"
:label="t('mail', 'SMTP Host')"
type="text"
Expand Down Expand Up @@ -291,6 +291,7 @@
} from '../service/AutoConfigService.js'
import { generateOauthState } from '../service/OauthStateService.js'
import useMainStore from '../store/mainStore.js'
import { isValidEmail } from '../util/emailAddress.js'

export default {
name: 'AccountForm',
Expand Down Expand Up @@ -385,7 +386,7 @@
return this.loading
}

return !this.emailAddress || !this.isValidEmail(this.emailAddress)
return !this.emailAddress || !this.validEmail(this.emailAddress)
|| (!this.googleOauthUrl && !this.autoConfig.password)
|| (!this.microsoftOauthUrl && !this.autoConfig.password)
},
Expand All @@ -399,7 +400,7 @@
return this.loading
}

return !this.emailAddress || !this.isValidEmail(this.emailAddress)
return !this.emailAddress || !this.validEmail(this.emailAddress)
|| !this.manualConfig.imapHost || !this.manualConfig.imapPort
|| !this.manualConfig.imapUser || (!this.useOauth && !this.manualConfig.imapPassword)
|| !this.manualConfig.smtpHost || !this.manualConfig.smtpPort
Expand Down Expand Up @@ -730,9 +731,8 @@
}
},

isValidEmail(email) {
const regExpEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(localhost|((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))$/
return regExpEmail.test(email)
validEmail(email) {
return isValidEmail(email)
},
},
}
Expand Down
9 changes: 8 additions & 1 deletion src/util/emailAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function tryParse(str) {
}

try {
return addressParser.parse(str).map((addr) => ({
return addressParser.parse(str).filter((addr) => {
return isValidEmail(addr.address)
}).map((addr) => ({
label: addr.name() || addr.address,
email: addr.address,
}))
Expand Down Expand Up @@ -130,3 +132,8 @@ export function parseEmailList(str) {
}
return list
}

export function isValidEmail(email) {
const regExpEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(localhost|((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))$/
return regExpEmail.test(email)
}
Loading