You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
filter out non-string display names
This commit is contained in:
@@ -129,7 +129,11 @@ User.prototype.setPresenceEvent = function(event) {
|
|||||||
*/
|
*/
|
||||||
User.prototype.setDisplayName = function(name) {
|
User.prototype.setDisplayName = function(name) {
|
||||||
const oldName = this.displayName;
|
const oldName = this.displayName;
|
||||||
|
if (typeof name === "string") {
|
||||||
this.displayName = name;
|
this.displayName = name;
|
||||||
|
} else {
|
||||||
|
this.displayName = undefined;
|
||||||
|
}
|
||||||
if (name !== oldName) {
|
if (name !== oldName) {
|
||||||
this._updateModifiedTime();
|
this._updateModifiedTime();
|
||||||
}
|
}
|
||||||
@@ -142,7 +146,11 @@ User.prototype.setDisplayName = function(name) {
|
|||||||
* @param {string} name The new display name.
|
* @param {string} name The new display name.
|
||||||
*/
|
*/
|
||||||
User.prototype.setRawDisplayName = function(name) {
|
User.prototype.setRawDisplayName = function(name) {
|
||||||
|
if (typeof name === "string") {
|
||||||
this.rawDisplayName = name;
|
this.rawDisplayName = name;
|
||||||
|
} else {
|
||||||
|
this.rawDisplayName = undefined;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -661,7 +661,9 @@ export function isNumber(value: any): boolean {
|
|||||||
* @return {string} a string with the hidden characters removed
|
* @return {string} a string with the hidden characters removed
|
||||||
*/
|
*/
|
||||||
export function removeHiddenChars(str: string): string {
|
export function removeHiddenChars(str: string): string {
|
||||||
|
if (typeof str === "string") {
|
||||||
return unhomoglyph(str.normalize('NFD').replace(removeHiddenCharsRegex, ''));
|
return unhomoglyph(str.normalize('NFD').replace(removeHiddenCharsRegex, ''));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regex matching bunch of unicode control characters and otherwise misleading/invisible characters.
|
// Regex matching bunch of unicode control characters and otherwise misleading/invisible characters.
|
||||||
|
|||||||
Reference in New Issue
Block a user