this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Sanitize multiple spaces in display names to protect against some security concerns (#5703)

authored by

Paul Frazee and committed by
GitHub
7677bb3f a8fb8dc6

+6 -1
+6 -1
src/lib/strings/display-names.ts
··· 7 7 const CHECK_MARKS_RE = /[\u2705\u2713\u2714\u2611]/gu 8 8 const CONTROL_CHARS_RE = 9 9 /[\u0000-\u001F\u007F-\u009F\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g 10 + const MULTIPLE_SPACES_RE = /[\s][\s]+/g 10 11 11 12 export function sanitizeDisplayName( 12 13 str: string, ··· 16 17 return '' 17 18 } 18 19 if (typeof str === 'string') { 19 - return str.replace(CHECK_MARKS_RE, '').replace(CONTROL_CHARS_RE, '').trim() 20 + return str 21 + .replace(CHECK_MARKS_RE, '') 22 + .replace(CONTROL_CHARS_RE, '') 23 + .replace(MULTIPLE_SPACES_RE, ' ') 24 + .trim() 20 25 } 21 26 return '' 22 27 }