You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-05 00:42:10 +03:00
Make the display_name check for contains rather than equality. Add UT.
This commit is contained in:
@@ -1363,15 +1363,15 @@ MatrixClient.prototype.inviteByEmail = function(roomId, email, displayName, call
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
* @throws If displayName === address.
|
||||
* @throws If <code>displayName</code> contains the <code>address</code>.
|
||||
*/
|
||||
MatrixClient.prototype.inviteByThreePid = function(roomId, medium, address,
|
||||
displayName, idServer, callback) {
|
||||
if (utils.isFunction(idServer)) { callback = idServer; idServer = undefined; }
|
||||
idServer = idServer || this.getIdentityServerUrl();
|
||||
if (displayName === address) {
|
||||
if (displayName && displayName.indexOf(address) >= 0) {
|
||||
throw new Error(
|
||||
"The display name is the same as the address. This leaks the 3PID " +
|
||||
"The display name contains the address. This leaks the 3PID " +
|
||||
"address to everyone in the room."
|
||||
);
|
||||
}
|
||||
|
@@ -372,5 +372,14 @@ describe("MatrixClient", function() {
|
||||
expect(httpLookups.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("should throw if the displayName contains the address in it",
|
||||
function() {
|
||||
expect(function() {
|
||||
client.inviteByEmail(
|
||||
roomId, "alice@gmail.com", "My Friend Alice (alice@gmail.com)"
|
||||
);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user