Files
webmail/lib/bidi.ts
T

13 lines
494 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Unicode directional formatting characters: the explicit embeddings,
* overrides and isolates (U+202A-202E, U+2066-2069) and the LRM/RLM marks.
* In a sender-controlled name they reorder what the reader sees, so
* `report‮fdp.exe` shows as `reportexe.pdf`.
*/
const BIDI_CONTROLS = /[‎‏‪-‮⁦-⁩]/g;
/** `text` without directional formatting characters, for display. */
export function stripBidiControls(text: string): string {
return text.replace(BIDI_CONTROLS, '');
}