Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

Commit bc9c08b

Browse files
authored
Merge pull request matrix-org#2338 from matrix-org/travis/validate-emails
Check to make sure email addresses look roughly valid before inviting them to rooms
2 parents 2ca7477 + d062e2c commit bc9c08b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/components/views/dialogs/AddressPickerDialog.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg';
2323
import Promise from 'bluebird';
2424
import { addressTypes, getAddressType } from '../../../UserAddress.js';
2525
import GroupStore from '../../../stores/GroupStore';
26+
import * as Email from "../../../email";
2627

2728
const TRUNCATE_QUERY_LIST = 40;
2829
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
@@ -419,6 +420,10 @@ module.exports = React.createClass({
419420
// a perfectly valid address if there are close matches.
420421
const addrType = getAddressType(query);
421422
if (this.props.validAddressTypes.includes(addrType)) {
423+
if (addrType === 'email' && !Email.looksValid(query)) {
424+
this.setState({searchError: _t("That doesn't look like a valid email address")});
425+
return;
426+
}
422427
suggestedList.unshift({
423428
addressType: addrType,
424429
address: query,

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@
874874
"Matrix ID": "Matrix ID",
875875
"Matrix Room ID": "Matrix Room ID",
876876
"email address": "email address",
877+
"That doesn't look like a valid email address": "That doesn't look like a valid email address",
877878
"You have entered an invalid address.": "You have entered an invalid address.",
878879
"Try using one of the following valid address types: %(validTypesList)s.": "Try using one of the following valid address types: %(validTypesList)s.",
879880
"Preparing to send logs": "Preparing to send logs",

0 commit comments

Comments
 (0)