You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Strip direction override characters from display names (#1992)
Strip RLO and LRO characters from name and rawDisplayName so they can safely be embedded into other text without messing up the text ordering. Fixes https://github.com/vector-im/element-web/issues/1712
This commit is contained in:
12
src/utils.ts
12
src/utils.ts
@@ -387,6 +387,18 @@ export function removeHiddenChars(str: string): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the direction override characters from a string
|
||||
* @param {string} input
|
||||
* @returns string with chars removed
|
||||
*/
|
||||
export function removeDirectionOverrideChars(str: string): string {
|
||||
if (typeof str === "string") {
|
||||
return str.replace(/[\u202d-\u202e]/g, '');
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function normalize(str: string): string {
|
||||
// Note: we have to match the filter with the removeHiddenChars() because the
|
||||
// function strips spaces and other characters (M becomes RN for example, in lowercase).
|
||||
|
||||
Reference in New Issue
Block a user