From 4a0b2641ebb0c9c797f1cd06f6b2401659c1f65d Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Mon, 5 Jul 2021 16:28:50 +1000 Subject: [PATCH] Revert "Update color-password.pipe.js to handle Unicode/Emoji correctly accross platforms. (#354)" This reverts commit b6f102938fe7c17631cb1b2e356438c5e4456529. Reason: incompatible with FF <= 77 --- angular/src/pipes/color-password.pipe.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/angular/src/pipes/color-password.pipe.ts b/angular/src/pipes/color-password.pipe.ts index 7ea50b81..96c4d497 100644 --- a/angular/src/pipes/color-password.pipe.ts +++ b/angular/src/pipes/color-password.pipe.ts @@ -3,20 +3,15 @@ import { PipeTransform, } from '@angular/core'; -/* - An updated pipe that sanitizes HTML, highlights numbers and special characters (in different colors each) - and handles Unicode / Emoji characters correctly. -*/ +/** + * A pipe that sanitizes HTML and highlights numbers and special characters (in different colors each). + */ @Pipe({ name: 'colorPassword' }) export class ColorPasswordPipe implements PipeTransform { transform(password: string) { - // Regex Unicode property escapes for checking if emoji in passwords. - const regexpEmojiPresentation = /\p{Emoji_Presentation}/gu; - // Convert to an array to handle cases that stings have special characters, ie: emoji. - const passwordArray = Array.from(password); let colorizedPassword = ''; - for (let i = 0; i < passwordArray.length; i++) { - let character = passwordArray[i]; + for (let i = 0; i < password.length; i++) { + let character = password[i]; let isSpecial = false; // Sanitize HTML first. switch (character) { @@ -40,9 +35,7 @@ export class ColorPasswordPipe implements PipeTransform { break; } let type = 'letter'; - if (character.match(regexpEmojiPresentation)) { - type = 'emoji'; - } else if (isSpecial || character.match(/[^\w ]/)) { + if (isSpecial || character.match(/[^\w ]/)) { type = 'special'; } else if (character.match(/\d/)) { type = 'number';